Skip to content
Snippets Groups Projects
Select Git revision
  • 446b29271cb9b18683115e8404367986baf60dda
  • 11.x default protected
  • 11.2.x protected
  • 10.6.x protected
  • 10.5.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
  • 10.4.5 protected
  • 11.0.13 protected
41 results

common.inc

Blame
  • Dries Buytaert's avatar
    - Patch #263517 by mfb: fixed notice in RSS feeds.
    Dries Buytaert authored
    446b2927
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    common.inc 119.31 KiB
    <?php
    // $Id$
    
    /**
     * @file
     * 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.
     */
    
    /**
     * Return status for saving which involved creating a new item.
     */
    define('SAVED_NEW', 1);
    
    /**
     * Return status for saving which involved an update to an existing item.
     */
    define('SAVED_UPDATED', 2);
    
    /**
     * Return status for saving which deleted an existing item.
     */
    define('SAVED_DELETED', 3);
    
    /**
     * Set content for a specified region.
     *
     * @param $region
     *   Page region the content is assigned to.
     * @param $data
     *   Content to be set.
     */
    function drupal_set_content($region = NULL, $data = NULL) {
      static $content = array();
    
      if (!is_null($region) && !is_null($data)) {
        $content[$region][] = $data;
      }
      return $content;
    }
    
    /**
     * Get assigned content.
     *
     * @param $region
     *   A specified region to fetch content for. If NULL, all regions will be
     *   returned.
     * @param $delimiter
     *   Content to be inserted between exploded array elements.
     */
    function drupal_get_content($region = NULL, $delimiter = ' ') {
      $content = drupal_set_content();
      if (isset($region)) {
        if (isset($content[$region]) && is_array($content[$region])) {
          return implode($delimiter, $content[$region]);
        }
      }
      else {
        foreach (array_keys($content) as $region) {
          if (is_array($content[$region])) {
            $content[$region] = implode($delimiter, $content[$region]);
          }
        }
        return $content;
      }
    }
    
    /**