예제 #1
0
파일: tablesort.py 프로젝트: vaibbhav/drupy
def get_querystring():
  """
   Compose a query string to append to table sorting requests.

   @return
     A query string that consists of all components of the current page request
     except for those pertaining to table sorting.
  """
  return lib_common.drupal_query_string_encode(
    _REQUEST, php.array_merge(['q', 'sort', 'order'], php.array_keys(_COOKIE)))
예제 #2
0
def template_preprocess_maintenance_page(variables):
  """
   The variables generated here is a mirror of template_preprocess_page().
   This preprocessor will run it's course when theme_maintenance_page() is
   invoked. It is also used in theme_install_page() and theme_update_page() to
   keep all the variables consistent.
  
   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
   - show_blocks
  
   @see maintenance-page.tpl.php
  """
  php.Reference.check(variables)
  # Add favicon
  if (theme_get_setting('toggle_favicon')):
    drupal_set_html_head('<link rel="shortcut icon" href="' + \
      check_url(theme_get_setting('favicon')) + '" type="image/x-icon" />');
  # Retrieve the theme data to list all available regions.
  theme_data = _system_theme_data()
  regions = theme_data[lib_appglobals.theme].info['regions']
  # Get all region content set with drupal_set_content().
  for region in php.array_keys(regions):
    # Assign region to a region variable.
    region_content = drupal_get_content(region)
    if php.isset(variables, region):
      variables[region] += region_content
    else:
      variables[region] = region_content
  # Setup layout variable.
  variables['layout'] = 'none'
  if (not php.empty(variables['left'])):
    variables['layout'] = 'left'
  if (not php.empty(variables['right'])):
    variables['layout'] = ('both' if \
      (variables['layout'] == 'left') else 'right')
  # Construct page title
  if (drupal_get_title()):
    head_title = [strip_tags(drupal_get_title()), \
      variable_get('site_name', 'Drupal')];
  else:
    head_title = [variable_get('site_name', 'Drupal')]
    if (variable_get('site_slogan', '')):
      head_title.append( variable_get('site_slogan', '') )
  variables['head_title']        = php.implode(' | ', head_title)
  variables['base_path']         = base_path()
  variables['front_page']        = url()
  variables['breadcrumb']        = ''
  variables['feed_icons']        = ''
  variables['footer_message']    = \
    filter_xss_admin(variable_get('site_footer', FALSE))
  variables['head']              = drupal_get_html_head()
  variables['help']              = ''
  variables['language']          = lib_appglobals.language
  variables['language'].dir      = \
    ('rtl' if lib_appglobals.language.direction else 'ltr')
  variables['logo']              = theme_get_setting('logo');
  variables['messages']          = (theme('status_messages') if \
    variables['show_messages'] else '')
  variables['mission']           = '';
  variables['main_menu']         = [];
  variables['secondary_menu']    = [];
  variables['search_box']        = '';
  variables['site_name']         = \
    (variable_get('site_name', 'Drupal') if \
    theme_get_setting('toggle_name')  else '')
  variables['site_slogan']       = (variable_get('site_slogan', '') if \
    theme_get_setting('toggle_slogan') else '')
  variables['css']               = drupal_add_css()
  variables['styles']            = drupal_get_css()
  variables['scripts']           = drupal_get_js()
  variables['tabs']              = ''
  variables['title']             = drupal_get_title();
  variables['closure']           = ''
  # Compile a list of classes that are going to be applied to the body element.
  body_classes = []
  body_classes.append( 'in-maintenance' )
  if (php.isset(variables, 'db_is_active') and \
      not variables['db_is_active']):
    body_classes.append( 'db-offline' )
  if (variables['layout'] == 'both'):
    body_classes.append( 'two-sidebars' )
  elif (variables['layout'] == 'none'):
    body_classes.append( 'no-sidebars' )
  else:
    body_classes.append( 'one-sidebar sidebar-'  + variables['layout'] )
  variables['body_classes'] = php.implode(' ', body_classes)
  # Dead databases will show error messages so supplying this template will
  # allow themers to override the page and the content completely.
  if (php.isset(variables, 'db_is_active') and \
      not variables['db_is_active']):
    variables['template_file'] = 'maintenance-page-offline';
예제 #3
0
def template_preprocess_maintenance_page(variables):
    """
   The variables generated here is a mirror of template_preprocess_page().
   This preprocessor will run it's course when theme_maintenance_page() is
   invoked. It is also used in theme_install_page() and theme_update_page() to
   keep all the variables consistent.
  
   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
   - show_blocks
  
   @see maintenance-page.tpl.php
  """
    php.Reference.check(variables)
    # Add favicon
    if (theme_get_setting('toggle_favicon')):
        drupal_set_html_head('<link rel="shortcut icon" href="' + \
          check_url(theme_get_setting('favicon')) + '" type="image/x-icon" />')
    # Retrieve the theme data to list all available regions.
    theme_data = _system_theme_data()
    regions = theme_data[lib_appglobals.theme].info['regions']
    # Get all region content set with drupal_set_content().
    for region in php.array_keys(regions):
        # Assign region to a region variable.
        region_content = drupal_get_content(region)
        if php.isset(variables, region):
            variables[region] += region_content
        else:
            variables[region] = region_content
    # Setup layout variable.
    variables['layout'] = 'none'
    if (not php.empty(variables['left'])):
        variables['layout'] = 'left'
    if (not php.empty(variables['right'])):
        variables['layout'] = ('both' if \
          (variables['layout'] == 'left') else 'right')
    # Construct page title
    if (drupal_get_title()):
        head_title = [strip_tags(drupal_get_title()), \
          variable_get('site_name', 'Drupal')]
    else:
        head_title = [variable_get('site_name', 'Drupal')]
        if (variable_get('site_slogan', '')):
            head_title.append(variable_get('site_slogan', ''))
    variables['head_title'] = php.implode(' | ', head_title)
    variables['base_path'] = base_path()
    variables['front_page'] = url()
    variables['breadcrumb'] = ''
    variables['feed_icons'] = ''
    variables['footer_message']    = \
      filter_xss_admin(variable_get('site_footer', FALSE))
    variables['head'] = drupal_get_html_head()
    variables['help'] = ''
    variables['language'] = lib_appglobals.language
    variables['language'].dir      = \
      ('rtl' if lib_appglobals.language.direction else 'ltr')
    variables['logo'] = theme_get_setting('logo')
    variables['messages']          = (theme('status_messages') if \
      variables['show_messages'] else '')
    variables['mission'] = ''
    variables['main_menu'] = []
    variables['secondary_menu'] = []
    variables['search_box'] = ''
    variables['site_name']         = \
      (variable_get('site_name', 'Drupal') if \
      theme_get_setting('toggle_name')  else '')
    variables['site_slogan']       = (variable_get('site_slogan', '') if \
      theme_get_setting('toggle_slogan') else '')
    variables['css'] = drupal_add_css()
    variables['styles'] = drupal_get_css()
    variables['scripts'] = drupal_get_js()
    variables['tabs'] = ''
    variables['title'] = drupal_get_title()
    variables['closure'] = ''
    # Compile a list of classes that are going to be applied to the body element.
    body_classes = []
    body_classes.append('in-maintenance')
    if (php.isset(variables, 'db_is_active') and \
        not variables['db_is_active']):
        body_classes.append('db-offline')
    if (variables['layout'] == 'both'):
        body_classes.append('two-sidebars')
    elif (variables['layout'] == 'none'):
        body_classes.append('no-sidebars')
    else:
        body_classes.append('one-sidebar sidebar-' + variables['layout'])
    variables['body_classes'] = php.implode(' ', body_classes)
    # Dead databases will show error messages so supplying this template will
    # allow themers to override the page and the content completely.
    if (php.isset(variables, 'db_is_active') and \
        not variables['db_is_active']):
        variables['template_file'] = 'maintenance-page-offline'