Skip to content

Commit

Permalink
Modifying preprocess and theme override functions
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickocoffeyo committed Jan 25, 2014
1 parent 0f76986 commit 3dc8b7b
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/breadcrumbs.inc
@@ -1,11 +1,11 @@
<?php
/**
* @file
* Modifies breadcrumb markup
* Overrides breadcrumb markup
*/

/**
* Implimenting hook_breadcrumb()
* Overriding theme_breadcrumb()
*/
function BootstrapBlocks_breadcrumb($variables) {
$breadcrumb = $variables['breadcrumb'];
Expand Down
23 changes: 23 additions & 0 deletions lib/containers.inc
@@ -0,0 +1,23 @@
<?php
/**
* @file
* Overrides container classes/markup
*/

/**
* Overriding theme_container()
*/
function BootstrapBlocks_container($variables) {
$element = $variables['element'];

if (isset($element['#array_parents'])) {
if (!isset($element['#attributes']['id'])) {
$element['#attributes']['id'] = $element['#id'];
}

$element['#attributes']['class'][] = 'form-wrapper';
$element['#attributes']['class'][] = 'form-group';
}

return '<div' . drupal_attributes($element['#attributes']) . '>' . $element['#children'] . '</div>';
}
18 changes: 18 additions & 0 deletions lib/forms.inc
Expand Up @@ -170,3 +170,21 @@ function BootstrapBlocks_progress_bar($variables) {

return '<div'. drupal_attributes($variables['attributes']) .'><div class="bar" style="width: '. $variables['percent'] .'%;"></div></div>';
}

/**
* Overrides theme_date().
*/
function BootstrapBlocks_date($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-inline';

return '<div' . drupal_attributes($attributes) . '>' . drupal_render_children($element) . '</div>';
}
67 changes: 67 additions & 0 deletions lib/lists.inc
@@ -0,0 +1,67 @@
<?php
/**
* @file
* Modifies item list markup
*/

/**
* Overrides theme_item_list().
*/
function BootstrapBlocks_item_list($variables) {
$items = $variables['items'];
$title = $variables['title'];
$type = $variables['type'];
$attributes = $variables['attributes'];
$output = '';

if (isset($title)) {
$output .= '<h3>' . $title . '</h3>';
}

if (!empty($items)) {
$output .= "<$type" . drupal_attributes($attributes) . '>';
$num_items = count($items);
$i = 0;
foreach ($items as $item) {
$attributes = array();
$children = array();
$data = '';
$i++;
if (is_array($item)) {
foreach ($item as $key => $value) {
if ($key == 'data') {
$data = $value;
}
elseif ($key == 'children') {
$children = $value;
}
else {
$attributes[$key] = $value;
}
}
}
else {
$data = $item;
}
if (count($children) > 0) {
// Render nested list.
$data .= theme('item_list', array(
'items' => $children,
'title' => NULL,
'type' => $type,
'attributes' => $attributes,
));
}
if ($i == 1) {
$attributes['class'][] = 'first';
}
if ($i == $num_items) {
$attributes['class'][] = 'last';
}
$output .= '<li' . drupal_attributes($attributes) . '>' . $data . "</li>\n";
}
$output .= "</$type>";
}

return $output;
}
1 change: 0 additions & 1 deletion lib/pagers.inc
Expand Up @@ -2,7 +2,6 @@
/**
* @file
* Overrides the default pager with a bootstrap pager.
* Partly borrowed from the Twitter Bootstrap project. Kudos!
*/

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/template-functions.php
Expand Up @@ -7,6 +7,8 @@
include('tables.inc');
include('fields.inc');
include('breadcrumbs.inc');
include('containers.inc');
include('lists.inc');

/*
* Return Header Scripts
Expand Down

0 comments on commit 3dc8b7b

Please sign in to comment.