From 9438279fd24e0309abd1f78a9442b149f7bd6bef Mon Sep 17 00:00:00 2001 From: bboldi Date: Tue, 13 Sep 2011 12:08:50 +0200 Subject: Initial commit. --- drupal7_theme_methods.php | 299 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100644 drupal7_theme_methods.php (limited to 'drupal7_theme_methods.php') diff --git a/drupal7_theme_methods.php b/drupal7_theme_methods.php new file mode 100644 index 0000000..f6b8d6f --- /dev/null +++ b/drupal7_theme_methods.php @@ -0,0 +1,299 @@ +' . t('You are here') . ''; + + $output .= '
' . implode(' ยป ', $breadcrumb) . '
'; + return $output; + } +} + +/** + * Returns HTML for a button form element. + * + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #attributes, #button_type, #name, #value. + * + * @ingroup themeable + */ +function b2_silly_clouds_button($variables) { + $element = $variables['element']; + $element['#attributes']['type'] = 'submit'; + element_set_attributes($element, array('id', 'name', 'value')); + + $element['#attributes']['class'][] = 'form-' . $element['#button_type'] . ' b2-button'; + if (!empty($element['#attributes']['disabled'])) { + $element['#attributes']['class'][] = 'form-button-disabled'; + } + + return ''. + ''. + ''. + ''. + ''; +} + +/** + * Override or insert variables into the page template. + */ +function b2_silly_clouds_preprocess_page(&$vars) { + $vars['tabs'] = menu_primary_local_tasks(); + $vars['tabs2'] = menu_secondary_local_tasks(); +} + +/** + * Returns HTML for a single local task link. + * + * @param $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. + * + * @ingroup themeable + */ +function b2_silly_clouds_menu_local_task($variables) { + $link = $variables['element']['#link']; + $link_text = $link['title']; + + if (!empty($variables['element']['#active'])) { + // Add text to indicate active tab for non-visual users. + $active = '' . t('(active tab)') . ''; + + // If the link does not contain HTML already, check_plain() it now. + // After we set 'html'=TRUE the link will not be sanitized by l(). + if (empty($link['localized_options']['html'])) { + $link['title'] = check_plain($link['title']); + } + $link['localized_options']['html'] = TRUE; + $link_text = t('!local-task-title!active', array('!local-task-title' => $link['title'], '!active' => $active)); + } + + //added b2-class + $link['localized_options']['attributes']['class'] = array('b2-button'); + + return '
  • ' . + ''. + ''. + ''. + l($link_text, $link['href'], $link['localized_options']) . + "
  • \n"; +} + +/** + * Returns HTML for a feed icon. + * + * @param $variables + * An associative array containing: + * - url: The url of the feed. + * - title: A descriptive title of the feed. + */ +function b2_silly_clouds_feed_icon($variables) { + $text = t('Subscribe to @feed-title', array('@feed-title' => $variables['title'])); + return l(NULL, $variables['url'], array('html' => TRUE, 'attributes' => array('class' => array('feed-icon', 'b2-rss-tag-icon'), 'title' => $text))); +} + +/** + * Returns HTML for a node preview for display during node creation and editing. + * + * @param $variables + * An associative array containing: + * - node: The node object which is being previewed. + * + * @ingroup themeable + */ +function b2_silly_clouds_node_preview($variables) { + $node = $variables['node']; + + $output = '
    '; + + $preview_trimmed_version = FALSE; + + $elements = node_view(clone $node, 'teaser'); + $trimmed = drupal_render($elements); + $elements = node_view($node, 'full'); + $full = drupal_render($elements); + + // Do we need to preview trimmed version of post as well as full version? + if ($trimmed != $full) { + 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. You can insert the delimiter "<!--break-->" (without the quotes) to fine-tune where your post gets split.')); + $preview_trimmed_version = t('Preview trimmed version'); + $output .= <<< EOT +
    +
    +
    + +
    + +

    + $preview_trimmed_version +

    + +
    +
    + + +
    + +
    +
    +
    + +EOT; + $output .= $trimmed; + + $preview_full_version = t('Preview full version'); + $output .= <<< EOT +
    +
    +
    + +
    + +

    + $preview_full_version +

    + +
    +
    + + +
    + +
    +
    +
    + +EOT; + + $output .= $full; + } + else { + $output .= $full; + } + $output .= "
    \n"; + + return $output; +} + +/** + * Return a Artisteer themed set of links. + * + * @param $content + * An object with node content. + * @return + * A string containing an unordered list of links. + */ +function art_links_woker_D7($content) { + $result = ''; + if (!isset($content['links'])) return $result; + foreach (array_keys($content['links']) as $name) { + $$name = & $content['links'][$name]; + if (isset($content['links'][$name]['#links'])) { + $links = $content['links'][$name]['#links']; + if (is_array($links)) { + $output = get_links_html_output_D7($links); + if (!empty($output)) { + $result .= (empty($result)) ? $output : ' | ' . $output; + } + } + } + } + +$terms = get_terms_D7($content); + if (!empty($terms)) { + ob_start();?> + ' . render($terms) . ''; + } + + + return $result; +} + +function get_terms_D7($content) { + $result = NULL; + foreach (array_keys($content) as $name) { + $$name = & $content[$name]; + $field_type = isset($content[$name]['#field_type']) ? $content[$name]['#field_type'] : NULL; + if ($field_type == null || $field_type != "taxonomy_term_reference") continue; + $result = $content[$name]; + } + return $result; +} + +function get_links_html_output_D7($links) { + $output = ''; + $num_links = count($links); + $index = 0; + + foreach ($links as $key => $link) { + $class = array($key); + + // Add first, last and active classes to the list of links to help out themers. + if ($index == 0) { + $class[] = 'first'; + } + if ($index == $num_links) { + $class[] = 'last'; + } + if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '' && drupal_is_front_page())) + && (empty($link['language']) || $link['language']->language == $language_url->language)) { + $class[] = 'active'; + } + + $link_output = ''; + + if (isset($link['href'])) { + // Pass in $link as $options, they share the same keys. + $link_output = l($link['title'], $link['href'], $link); + } + elseif (!empty($link['title'])) { + // Some links are actually not links, but we wrap these in for adding title and class attributes. + if (empty($link['html'])) { + $link['title'] = check_plain($link['title']); + } + $span_attributes = ''; + if (isset($link['attributes'])) { + $span_attributes = drupal_attributes($link['attributes']); + } + $link_output = '' . $link['title'] . ''; + } + +if (strpos ($key, "comment") !== FALSE) { + + if ($index > 0 && !empty($link_output) && !empty($output)) { + $output .= ' | '; + } + ob_start();?> + 0 && !empty($link_output) && !empty($output)) { + $output .= ' | '; + } + ob_start();?> +