/**
 * Overrides theme_file_managed_file().
 */
function springy_file_managed_file($variables)
{
    $element = $variables['element'];
    $attributes = array();
    if (isset($element['#id'])) {
        $attributes['id'] = $element['#id'];
    }
    if (!empty($element['#attributes']['class'])) {
        $attributes['class'] = (array) $element['#attributes']['class'];
    }
    $attributes['class'][] = 'form-managed-file';
    $attributes['class'][] = 'input-group';
    $element['upload_button']['#prefix'] = '<span class="input group-btn">';
    $element['upload_button']['#suffix'] = '</span>';
    $element['remove_button']['#prefix'] = '<span class="input group-btn">';
    $element['remove_button']['#suffix'] = '</span>';
    if (!empty($element['filename'])) {
        $element['filename']['#prefix'] = '<div class="form-control">';
        $element['filename']['#suffix'] = '</div>';
    }
    $hidden_elements = array();
    foreach (element_children($element) as $child) {
        if ($element[$child]['#type'] === 'hidden') {
            $hidden_elements[$child] = $element[$child];
            unset($element[$child]);
        }
    }
    // This wrapper is required to apply JS behaviors and CSS styling.
    $output = '';
    $output .= '<div' . drupal_attributes($attributes) . '>';
    $output .= drupal_render_children($element);
    $output .= '</div>';
    $output .= render($hidden_elements);
    return $output;
}
Example #2
0
/**
 * Theme function to display the revisions formular.
 *
 * Overridden to simply change some terminology (e.g. current revison -> current
 * version).
 */
function pol_proc_admin_diff_node_revisions($vars)
{
    $form = $vars['form'];
    $output = '';
    // Overview table:
    $header = array(t('Revision'), array('data' => drupal_render($form['submit']), 'colspan' => 2), array('data' => t('Operations'), 'colspan' => 2));
    if (isset($form['info']) && is_array($form['info'])) {
        foreach (element_children($form['info']) as $key) {
            $row = array();
            if (isset($form['operations'][$key][0])) {
                // Note: even if the commands for revert and delete are not permitted,
                // the array is not empty since we set a dummy in this case.
                $row[] = drupal_render($form['info'][$key]);
                $row[] = drupal_render($form['diff']['old'][$key]);
                $row[] = drupal_render($form['diff']['new'][$key]);
                $row[] = drupal_render($form['operations'][$key][0]);
                $row[] = drupal_render($form['operations'][$key][1]);
                $rows[] = array('data' => $row, 'class' => array('diff-revision'));
            } else {
                // The current revision (no commands to revert or delete).
                $row[] = array('data' => drupal_render($form['info'][$key]), 'class' => array('revision-current'));
                $row[] = array('data' => drupal_render($form['diff']['old'][$key]), 'class' => array('revision-current'));
                $row[] = array('data' => drupal_render($form['diff']['new'][$key]), 'class' => array('revision-current'));
                $row[] = array('data' => t('current version'), 'class' => array('revision-current'), 'colspan' => '2');
                $rows[] = array('data' => $row, 'class' => array('error diff-revision'));
            }
        }
    }
    $output .= theme('table__diff__revisions', array('header' => $header, 'rows' => $rows, 'sticky' => FALSE, 'attributes' => array('class' => 'diff-revisions')));
    $output .= drupal_render_children($form);
    return $output;
}
Example #3
0
function wspine_test_preprocess_page(&$vars, $hook)
{
    if (isset($vars['node_title'])) {
        $vars['title'] = $vars['node_title'];
    }
    // Adding a class to #page in wireframe mode
    if (theme_get_setting('wireframe_mode')) {
        $vars['classes_array'][] = 'wireframe-mode';
    }
    // Adding classes wether #navigation is here or not
    if (!empty($vars['main_menu']) or !empty($vars['sub_menu'])) {
        $vars['classes_array'][] = 'with-navigation';
    }
    if (!empty($vars['secondary_menu'])) {
        $vars['classes_array'][] = 'with-subnav';
    }
    // Add first/last classes to node listings about to be rendered.
    if (isset($vars['page']['content']['system_main']['nodes'])) {
        // All nids about to be loaded (without the #sorted attribute).
        $nids = element_children($vars['page']['content']['system_main']['nodes']);
        // Only add first/last classes if there is more than 1 node being rendered.
        if (count($nids) > 1) {
            $first_nid = reset($nids);
            $last_nid = end($nids);
            $first_node = $vars['page']['content']['system_main']['nodes'][$first_nid]['#node'];
            $first_node->classes_array = array('first');
            $last_node = $vars['page']['content']['system_main']['nodes'][$last_nid]['#node'];
            $last_node->classes_array = array('last');
        }
    }
}
Example #4
0
/**
 * Implements theme_process_page().
 */
function basetpl_process_page(&$variables)
{
    global $base_path;
    // show/hide breadcrumb
    $variables['show_breadcrumb'] = TRUE;
    // var theme_path
    $variables['theme_path'] = $base_path . path_to_theme();
    // var site_info
    $variables['site_info'] = $variables['logo'] || $variables['site_name'] || $variables['site_slogan'] ? TRUE : FALSE;
    // check if page is system page
    $variables['system_page'] = isset($variables['node']) ? FALSE : TRUE;
    // backend
    if (user_is_logged_in() && path_is_admin(current_path())) {
        $variables['site_info'] = FALSE;
        $variables['system_page'] = TRUE;
        foreach (element_children($variables['page']) as $region) {
            if ($region != 'content') {
                $variables['page'][$region] = FALSE;
            }
        }
    }
    // show/hide page title
    $variables['title'] = $variables['system_page'] ? $variables['title'] : FALSE;
    // add robots to head
    if (theme_get_setting('robots') == 1) {
        $robots = array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('name' => 'robots', 'content' => 'noindex,nofollow'));
        drupal_add_html_head($robots, 'robots');
    }
}
/**
 * Overrides theme_file_widget().
 */
function bootstrap_file_widget($variables)
{
    $element = $variables['element'];
    $output = '';
    $hidden_elements = array();
    foreach (element_children($element) as $child) {
        if (isset($element[$child]['#type']) && $element[$child]['#type'] === 'hidden') {
            $hidden_elements[$child] = $element[$child];
            unset($element[$child]);
        }
    }
    $element['upload_button']['#prefix'] = '<span class="input-group-btn">';
    $element['upload_button']['#suffix'] = '</span>';
    // The "form-managed-file" class is required for proper Ajax functionality.
    if (!empty($element['filename'])) {
        $output .= '<div class="file-widget form-managed-file clearfix">';
        // Add the file size after the file name.
        $element['filename']['#markup'] .= ' <span class="file-size badge">' . format_size($element['#file']->filesize) . '</span>';
    } else {
        $output .= '<div class="file-widget form-managed-file clearfix input-group">';
    }
    $output .= drupal_render_children($element);
    $output .= '</div>';
    $output .= render($hidden_elements);
    return $output;
}
Example #6
0
/**
 * Alters the node form on pre_render -ie. after all the real form processing
 * happened- thus ensuring we can move elements around without interacting with
 * form validation and submission processes.
 */
function badm_form_node_form_pre_render($form)
{
    if (!isset($form['additional_settings']) || isset($form['additional_settings']['#access']) && !$form['additional_settings']['#access'] || isset($form['additional_settings']['additional_settings__active_tab']) && count(element_children($form['additional_settings']['additional_settings__active_tab'])) == 0) {
        return $form;
    }
    // Exclude all non visible items. Note that fieldset will have a specific
    // case in the foreach loop.
    $excluded_types = ['value' => true, 'hidden' => true, 'token' => true, 'actions' => true, 'vertical_tabs' => true];
    foreach (element_children($form) as $key) {
        $element = $form[$key];
        $type = isset($element['#type']) ? $element['#type'] : null;
        if (isset($excluded_types[$type])) {
            continue;
        }
        switch ($type) {
            case 'fieldset':
                if (isset($element['#group']) && 'additional_settings' === $element['#group']) {
                    // Leave the ungrouped fieldset go down the road to the default
                    // behavior and be moved into the orphans container.
                    break;
                }
            default:
                $form['node_form_orphans'][$key] = $element;
                // This breaks ordering... Ideally ordering would need to be restored
                // at the field config level in order to avoid further bad surprises
                // but instead we just force the reordering below.
                unset($form[$key]);
                break;
        }
    }
    uasort($form['node_form_orphans'], 'element_sort');
    // Activate tab.
    $form['node_form_orphans']['#access'] = TRUE;
    return $form;
}
Example #7
0
/**
 * Display a view as a grid style.
 */
function reset_preprocess_views_view_grid(&$vars)
{
    drupal_add_css(drupal_get_path('theme', 'reset') . '/css/views-view-grid.css');
    foreach (element_children($vars['row_classes']) as $key => $value) {
        $vars['row_classes'][$key] .= 'view-grid-row has-' . $vars['options']['columns'] . '-cols';
    }
}
Example #8
0
/**
 * Overrides theme_file_widget().
 */
function bootstrap_file_widget($variables)
{
    $output = '';
    $element = $variables['element'];
    $element['upload_button']['#attributes']['class'][] = 'btn-primary';
    $element['upload_button']['#prefix'] = '<span class="input-group-btn">';
    $element['upload_button']['#suffix'] = '</span>';
    // The "form-managed-file" class is required for proper Ajax functionality.
    if (!empty($element['filename'])) {
        $output .= '<div class="file-widget form-managed-file clearfix">';
        // Add the file size after the file name.
        $element['filename']['#markup'] .= ' <span class="file-size badge">' . format_size($element['#file']->filesize) . '</span>';
    } else {
        $output .= '<div class="file-widget form-managed-file clearfix input-group">';
    }
    // Immediately render hidden elements before the rest of the output.
    // The uploadprogress extension requires that the hidden identifier input
    // element appears before the file input element. They must also be siblings
    // inside the same parent element.
    // @see https://www.drupal.org/node/2155419
    foreach (element_children($element) as $child) {
        if (isset($element[$child]['#type']) && $element[$child]['#type'] === 'hidden') {
            $output .= drupal_render($element[$child]);
        }
    }
    // Render the rest of the element.
    $output .= drupal_render_children($element);
    $output .= '</div>';
    return $output;
}
Example #9
0
/**
 * Implements template_preprocess_html().
 */
function druio_theme_preprocess_html(&$variables)
{
    // Redefine body classes.
    $variables['classes_array'] = array();
    $element_children = element_children($variables['page']['sidebar']);
    if (!empty($element_children)) {
        $variables['classes_array'][] = 'sidebar';
    } else {
        $variables['classes_array'][] = 'no-sidebars';
    }
    if (drupal_is_front_page()) {
        $variables['classes_array'][] = 'frontpage';
    }
    if (user_is_logged_in()) {
        $variables['classes_array'][] = 'registered';
    } else {
        $variables['classes_array'][] = 'anonymous';
    }
    $status = drupal_get_http_header("status");
    if ($status == "404 Not Found") {
        $variables['classes_array'][] = drupal_html_class('page-404');
    }
    if ($status == "403 Forbidden") {
        $variables['classes_array'][] = drupal_html_class('page-403');
    }
}
Example #10
0
function tradjenta_qt_quicktabs_tabset($vars)
{
    $variables = array('attributes' => array('class' => 'quicktabs-tabs m-tabs-header quicktabs-style-' . $vars['tabset']['#options']['style']), 'items' => array());
    $last_key = key(array_slice($vars['tabset']['tablinks'], -1, 1, TRUE));
    foreach (element_children($vars['tabset']['tablinks']) as $key) {
        $item = array();
        if (is_array($vars['tabset']['tablinks'][$key])) {
            $tab = $vars['tabset']['tablinks'][$key];
            $item['class'] = array('tab');
            if ($key == $vars['tabset']['#options']['active']) {
                array_push($item['class'], 'active');
            }
            switch ($key) {
                case '0':
                    array_push($item['class'], 'tab-straight', 'tab-straight-left');
                    break;
                case '1':
                    array_push($item['class'], 'tab-skewed', 'tab-skewed-first');
                    break;
                case '2':
                    array_push($item['class'], 'tab-skewed', 'tab-skewed-last');
                    break;
                case '3':
                    array_push($item['class'], 'tab-straight', 'tab-straight-right');
                    break;
                default:
                    array_push($item['class'], 'tab-skewed', 'tab-skewed-first');
                    break;
            }
            $item['data'] = drupal_render($tab);
            $variables['items'][] = $item;
        }
    }
    return theme('item_list', $variables);
}
Example #11
0
function walkhub_theme_form_walkthrough_set_node_form_alter(&$form, &$form_state, $form_id)
{
    if (!empty($form['field_walkthroughs'][LANGUAGE_NONE])) {
        foreach (element_children($form['field_walkthroughs'][LANGUAGE_NONE]) as $key) {
            $form['field_walkthroughs'][LANGUAGE_NONE][$key]['#theme'] = 'walkthrough_set_steps_edit_form';
        }
    }
}
Example #12
0
/**
 * Pre-processes variables for the "admin_menu_links" theme hook.
 *
 * @param array $variables
 *   - elements: A renderable array of links using the following keys:
 *     - #attributes: Optional array of attributes for the list item, processed
 *       via drupal_attributes().
 *     - #title: Title of the link, passed to l().
 *     - #href: Optional path of the link, passed to l(). When omitted, the
 *       element's '#title' is rendered without link.
 *     - #description: Optional alternative text for the link, passed to l().
 *     - #options: Optional alternative text for the link, passed to l().
 *     The array key of each child element itself is passed as path for l().
 *
 * @see theme_admin_menu_links()
 *
 * @ingroup theme_preprocess
 */
function bootstrap_preprocess_admin_menu_links(&$variables)
{
    $elements =& $variables['elements'];
    foreach (element_children($elements) as $child) {
        $elements[$child]['#bootstrap_ignore_pre_render'] = TRUE;
        $elements[$child]['#bootstrap_ignore_process'] = TRUE;
    }
}
Example #13
0
/**
 * Helper function to output a Drupal menu as a Foundation Top Bar.
 *
 * @links array
 *   An array of menu links.
 *
 * @return string
 *   A rendered list of links, with no <ul> or <ol> wrapper.
 *
 * @see mdl_links__system_main_menu()
 * @see mdl_links__system_secondary_menu()
 */
function _mdl_links($links)
{
    $output = '';
    foreach (element_children($links) as $key) {
        $output .= _mdl_render_link($links[$key]);
    }
    return $output;
}
Example #14
0
/**
 * Overrides theme_devconnect_monetization_recurring_balances().
 */
function apigee_responsive_devconnect_monetization_recurring_balances($vars)
{
    $rows = array();
    foreach (element_children($vars['balances']['items']) as $currency) {
        $rows[] = array(array('data' => $vars['balances']['items'][$currency]['charge_per_usage']), array('data' => $vars['balances']['items'][$currency]['is_recurring']), array('data' => $vars['balances']['items'][$currency]['#provider']), array('data' => $vars['balances']['items'][$currency]['#currency']), array('data' => $vars['balances']['items'][$currency]['recurring_amount']), array('data' => $vars['balances']['items'][$currency]['replenish_amount']));
    }
    $header = array(t('Charge per Usage'), t('Recurring'), t('Provider'), t('Currency'), t('Recurring Amount'), t('Replenish Amount'));
    return '<div class="table-responsive">' . theme('table', array('header' => $header, 'rows' => $rows)) . '</div>';
}
Example #15
0
/**
 * Process variables for comment.tpl.php.
 *
 * @see comment.tpl.php
 */
function unikue_preprocess_comment(&$variables)
{
    $comment = $variables['elements']['#comment'];
    $node = $variables['elements']['#node'];
    $variables['comment'] = $comment;
    $variables['node'] = $node;
    $variables['author'] = theme('username', array('account' => $comment));
    $variables['created'] = date('d F Y', $comment->created);
    // Avoid calling format_date() twice on the same timestamp.
    if ($comment->changed == $comment->created) {
        $variables['changed'] = $variables['created'];
    } else {
        $variables['changed'] = format_date($comment->changed);
    }
    $variables['new'] = !empty($comment->new) ? t('new') : '';
    $variables['picture'] = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', array('account' => $comment)) : '';
    $variables['signature'] = $comment->signature;
    $uri = entity_uri('comment', $comment);
    $uri['options'] += array('attributes' => array('class' => 'permalink', 'rel' => 'bookmark'));
    $variables['title'] = l($comment->subject, $uri['path'], $uri['options']);
    $variables['permalink'] = l(t('Permalink'), $uri['path'], $uri['options']);
    $variables['submitted'] = t('!username  on !datetime', array('!username' => $variables['author'], '!datetime' => date('d/m/Y', $comment->created)));
    // Preprocess fields.
    field_attach_preprocess('comment', $comment, $variables['elements'], $variables);
    // Helpful $content variable for templates.
    foreach (element_children($variables['elements']) as $key) {
        $variables['content'][$key] = $variables['elements'][$key];
    }
    // Set status to a string representation of comment->status.
    if (isset($comment->in_preview)) {
        $variables['status'] = 'comment-preview';
    } else {
        $variables['status'] = $comment->status == COMMENT_NOT_PUBLISHED ? 'comment-unpublished' : 'comment-published';
    }
    // Gather comment classes.
    // 'comment-published' class is not needed, it is either 'comment-preview' or
    // 'comment-unpublished'.
    if ($variables['status'] != 'comment-published') {
        $variables['classes_array'][] = $variables['status'];
    }
    if ($variables['new']) {
        $variables['classes_array'][] = 'comment-new';
    }
    if (!$comment->uid) {
        $variables['classes_array'][] = 'comment-by-anonymous';
    } else {
        if ($comment->uid == $variables['node']->uid) {
            $variables['classes_array'][] = 'comment-by-node-author';
        }
        if ($comment->uid == $variables['user']->uid) {
            $variables['classes_array'][] = 'comment-by-viewer';
        }
    }
    foreach ($variables['content']['links']['comment']['#links'] as $key => $value) {
        $variables['content']['links']['comment']['#links'][$key]['attributes']['class'] = array('button button-small');
    }
}
Example #16
0
 protected function setFilterRadioValues(&$element, $value, $property = '#default_value')
 {
     foreach (element_children($element) as $key) {
         // special hack for fieldset containing filter radios...
         if (isset($element[$key]['#type']) && $element[$key]['#type'] == 'radio') {
             $element[$key][$property] = $value;
         }
     }
 }
Example #17
0
/**
 * Theme function for manage options on admin/content/node, admin/user/user.
 */
function cleanr_admin_manage_options($form)
{
    $output = "<div class='clear-block admin-options'>";
    $output .= "<label>{$form['#title']}</label>";
    foreach (element_children($form) as $id) {
        $output .= drupal_render($form[$id]);
    }
    $output .= "</div>";
    return $output;
}
Example #18
0
function theme_tac_term_list($variables)
{
    $form = $variables['form'];
    $headers = array('Term', 'List', 'Create', 'Update', 'Delete');
    $rows = array();
    foreach (element_children($form) as $key) {
        $rows[] = array('data' => array($form[$key]['#title'], drupal_render($form[$key]['list']), drupal_render($form[$key]['create']), drupal_render($form[$key]['update']), drupal_render($form[$key]['delete'])));
    }
    return theme('table', array('header' => $headers, 'rows' => $rows, 'caption' => $form['#title']));
}
Example #19
0
function myphp_preprocess_page(&$variables)
{
    $variables['sidebar_search_form'] = '';
    if (isset($variables['page']['sidebar_search_form'])) {
        foreach (element_children($variables['page']['sidebar_search_form']) as $key) {
            if (isset($variables['page']['sidebar_search_form'][$key]['#markup'])) {
                $variables['sidebar_search_form'] .= $variables['page']['sidebar_search_form'][$key]['#markup'];
            }
        }
    }
}
Example #20
0
/**
 * override theme function for spaces_features_form().
 * @see spaces/spaces.theme.inc
 * The only thing this does is add class 'enabled' to the 
 * row of the enabled features 
 */
function cp_theme_spaces_features_form($form)
{
    $rows = array();
    $spaces_features = variable_get('spaces_features', array());
    foreach (element_children($form['spaces_features']) as $f_name => $feature) {
        $class = $spaces_features[$feature] ? 'enabled' : '';
        $rows[] = array('data' => array(array('class' => 'name', 'data' => drupal_render($form['labels'][$feature])), array('class' => 'option', 'data' => drupal_render($form['spaces_features'][$feature])), array('class' => 'actions', 'data' => drupal_render($form['settings'][$feature]))), 'class' => $class);
    }
    $output = theme('table', array(), $rows, array('class' => 'spaces-features'));
    $output .= drupal_render($form);
    return $output;
}
Example #21
0
/**
 * Helper function to fix theme hooks in book TOC menus.
 *
 * @param int $bid
 *   The book identification number.
 * @param array $element
 *   The element to iterate over, passed by reference.
 * @param int $level
 *   Used internally to determine the current level of the menu.
 */
function _bootstrap_book_fix_theme_hooks($bid, array &$element, $level = 0)
{
    $hook = $level === 0 ? $bid : 'sub_menu__' . $bid;
    $element['#theme_wrappers'] = array('menu_tree__book_toc__' . $hook);
    foreach (element_children($element) as $child) {
        $element[$child]['#theme'] = 'menu_link__book_toc__' . $hook;
        // Iterate through all child menu items as well.
        if (!empty($element[$child]['#below'])) {
            _bootstrap_book_fix_theme_hooks($bid, $element[$child]['#below'], $level + 1);
        }
    }
}
 /**
  * Constructs a ChecklistapiChecklist object.
  *
  * @param array $definition
  *   A checklist definition, as returned by checklistapi_get_checklist_info().
  */
 public function __construct(array $definition)
 {
     foreach (element_children($definition) as $group_key) {
         $this->totalItems += count(element_children($definition[$group_key]));
         $this->items[$group_key] = $definition[$group_key];
         unset($definition[$group_key]);
     }
     foreach ($definition as $property_key => $value) {
         $property_name = checklistapi_strtolowercamel(drupal_substr($property_key, 1));
         $this->{$property_name} = $value;
     }
     $this->savedProgress = variable_get($this->getSavedProgressVariableName(), array());
 }
Example #23
0
/**
 * Implements hook_page_alter().
 * https://gist.github.com/jacine/1378246
 */
function dandeleon_page_alter(&$page)
{
    // Remove all the region wrappers.
    foreach (element_children($page) as $key => $region) {
        if (!empty($page[$region]['#theme_wrappers'])) {
            $page[$region]['#theme_wrappers'] = array_diff($page[$region]['#theme_wrappers'], array('region'));
        }
    }
    // Remove the wrapper from the main content block.
    if (!empty($page['content']['system_main'])) {
        $page['content']['system_main']['#theme_wrappers'] = array_diff($page['content']['system_main']['#theme_wrappers'], array('block'));
    }
}
Example #24
0
/**
 * Helper function for cloning and drupal_render()'ing elements.
 */
function cuseven_render_clone($elements)
{
    static $instance;
    if (!isset($instance)) {
        $instance = 1;
    }
    foreach (element_children($elements) as $key) {
        if (isset($elements[$key]['#id'])) {
            $elements[$key]['#id'] = "{$elements[$key]['#id']}-{$instance}";
        }
    }
    $instance++;
    return drupal_render($elements);
}
/**
 * Theme the providers table.
 *
 * @ingroup themeable
 */
function theme_entityreference_prepopulate_providers_table($variables)
{
    $form = $variables['form'];
    $provider_names = element_children($form['enabled']);
    foreach ($provider_names as $provider_name) {
        $row = array('data' => array(drupal_render($form['title'][$provider_name]), drupal_render($form['enabled'][$provider_name]), drupal_render($form['weight'][$provider_name])), 'class' => array('draggable'));
        $rows[] = $row;
    }
    $header = array(array('data' => t('Provider')), array('data' => t('Enabled')), array('data' => t('Weight')));
    $table_variables = array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'table-providers'));
    $output = theme('table', $table_variables);
    drupal_add_tabledrag('table-providers', 'order', 'sibling', 'provider-weight');
    return $output;
}
Example #26
0
 function hook_preprocess_foundation_topbar(&$variables)
 {
     foreach (element_children($variables['links_left']) as $i) {
         // php 5.4 will complain about references without this extra affectation...
         $this->add_active_class($link =& $variables['links_left'][$i]);
         // add link id for theming
         $variables['links_left'][$i]['#attributes']['id'] = 'link-' . $i;
     }
     foreach (element_children($variables['links_right']) as $i) {
         $this->add_active_class($link =& $variables['links_right'][$i]);
         // add link id for theming
         $variables['links_right'][$i]['#attributes']['id'] = 'link-' . $i;
     }
 }
Example #27
0
/**
 * Removes information from the node.
 *
 * Request that $node parameters that are expected to be protected to somehow
 * be removed from the $node.
 *
 * This function gives 3rd party modules adding content to a node a chance for
 * hiding that content before it gets displayed or indexed.
 *
 * The default implementation hides the fields. It either replace the title with
 * "Password protected page" or keeps it intact depending on the protected node
 * "Show Title" flag.
 *
 * The hook is only invoked when the node is protected and the user did not yet
 * provide the correct password.
 *
 * @see protected_node_protected_node_hide()
 */
function hook_protected_node_hide(&$node)
{
    // Core module fields.
    if (!$node->protected_node_show_title) {
        $node->title = t('Password protected page');
    }
    $node->body = '';
    // Remove $node->content children to avoid the user see content he/she should
    // not see.
    $content_children = element_children($node->content);
    foreach ($content_children as $content_key) {
        unset($node->content[$content_key]);
    }
}
Example #28
0
/**
 * Preprocessor for handling form button for most forms.
 */
function rubik_preprocess_form_buttons(&$vars)
{
    if (isset($vars['form']['buttons'])) {
        $vars['buttons'] = $vars['form']['buttons'];
        unset($vars['form']['buttons']);
    } else {
        $vars['buttons'] = array();
        foreach (element_children($vars['form']) as $key) {
            if (isset($vars['form'][$key]['#type']) && in_array($vars['form'][$key]['#type'], array('submit', 'button'))) {
                $vars['buttons'][$key] = $vars['form'][$key];
                unset($vars['form'][$key]);
            }
        }
    }
}
Example #29
0
/**
 * Implements hook_form_alter().
 */
function drupalmel_theme_form_alter(&$form, $form_state, $form_id)
{
    if (isset($form['#entity_type']) && $form['#entity_type'] == 'entityform') {
        foreach (element_children($form) as $child) {
            $langcode = isset($form['child']['#language']) ? $form['child']['#language'] : LANGUAGE_NONE;
            if (isset($form[$child][$langcode][0])) {
                foreach (element_children($form[$child][$langcode][0]) as $value) {
                    if (in_array($value, array('email', 'value')) && $form[$child][$langcode][0][$value]['#type'] == 'textfield') {
                        $form[$child][$langcode][0][$value]['#attributes']['placeholder'] = $form[$child][$langcode][0][$value]['#title'];
                        $form[$child][$langcode][0][$value]['#title_display'] = 'invisible';
                    }
                }
            }
        }
        $form['actions']['submit']['#attributes']['class'][] = 'btn-primary';
    }
}
 /**
  * Provide the actual editing form.
  */
 function edit_form(&$form, &$form_state)
 {
     parent::edit_form($form, $form_state);
     $settings = $form_state['item']->settings;
     $new = TRUE;
     $form['label'] = array('#type' => 'textfield', '#title' => t('Label'), '#default_value' => isset($form_state['item']->label) ? $form_state['item']->label : array(), '#size' => 60, '#maxlength' => 128, '#required' => TRUE, '#attributes' => $new ? array() : array('readonly' => 'readonly'));
     $form['module'] = array('#type' => 'textfield', '#title' => t('Module'), '#default_value' => isset($form_state['item']->module) ? $form_state['item']->module : array(), '#size' => 60, '#maxlength' => 128, '#required' => TRUE, '#attributes' => $new ? array() : array('readonly' => 'readonly'));
     $form['settings'] = array('#type' => 'fieldset', '#title' => t('Settings'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#tree' => TRUE, '#group' => 'general-tab');
     $plugin_name = $form_state['item']->plugin_name;
     $pluginWrapper = heartbeat_plugins_get_plugin($plugin_name);
     if ($pluginWrapper instanceof iHeartbeatPluginWrapper) {
         $plugin = $pluginWrapper->getPlugin();
         if ($plugin) {
             $plugin->pluginUIForm($form, $form_state);
         }
         $new = FALSE;
     }
     if ($new) {
         $form['settings']['attachment'] = array('#type' => 'checkbox', '#title' => t('Attachment'), '#default_value' => isset($settings['attachment']) ? $settings['attachment'] : array());
     }
     if (!element_children($form['settings'])) {
         unset($form['settings']);
     }
     // Clear the cache for heartbeat plugins.
     cache_clear_all('heartbeat_plugins', 'cache');
 }