function custom_breadcrumbs_load_breadcrumbs in Custom Breadcrumbs 6.2
Same name and namespace in other branches
- 7.2 custom_breadcrumbs.module \custom_breadcrumbs_load_breadcrumbs()
Loads the custom breadcrumb from submodule table.
Parameters
$module: The name of the custom breadcrumbs submodule managing the requested breadcrumb. @param $table The name of the table to limit the search to. This only needs to be provided if the submodule provides breadcrumbs from more than one table. @param $param An array of the form 'field' => $value used in the SQL WHERE clause.
@return if $param is empty, all breadcrumbs from the table will be returned as an array otherwise a single breadcrumb object is be returned.
23 calls to custom_breadcrumbs_load_breadcrumbs()
- custom_breadcrumbsapi_breadcrumb_alter in custom_breadcrumbsapi/
custom_breadcrumbsapi.module - Implements hook_breadcrumb_alter().
- custom_breadcrumbsapi_form in custom_breadcrumbsapi/
custom_breadcrumbsapi.module - Form builder; Displays an edit form for a module page breadcrumb.
- custom_breadcrumbsapi_preprocess in custom_breadcrumbsapi/
custom_breadcrumbsapi.module - Implements hook_preprocess().
- custom_breadcrumbs_form in ./
custom_breadcrumbs.admin.inc - Form builder to edit a custom breadcrumb record.
- custom_breadcrumbs_form_alter in ./
custom_breadcrumbs.module - Implements hook_form_alter().
File
- ./
custom_breadcrumbs.module, line 681 - Provide custom breadcrumbs for node-type pages and base functionality for submodules to add custom breadcrumbs for other types of pages.
Code
function custom_breadcrumbs_load_breadcrumbs($module, $table = NULL, $param = array(), $languages = array()) {
static $breadcrumbs_cache = array();
$breadcrumbs = array();
$bc_info = module_invoke($module, 'cb_breadcrumb_info');
foreach ($bc_info as $info) {
if (!isset($table) || $info['table'] == $table) {
$args = array();
$cond = array();
$cond_string = array();
$sql = "SELECT * FROM {" . $info['table'] . "}";
if ($p = !empty($param)) {
$sql .= " WHERE ";
foreach ($param as $key => $value) {
$cond[] = db_escape_string($key) . " = '%s'";
$args[] = $value;
$cond_string[] = $key . '_' . $value;
}
if (!empty($cond)) {
$sql .= implode(' AND ', $cond);
}
}
if (!empty($languages)) {
$sql .= $p ? " AND " : " WHERE ";
$sql .= "language IN (" . db_placeholders($languages, 'text') . ") ORDER BY language ASC";
$args = array_merge($args, $languages);
}
$ckey = "{$info['table']}-{" . implode('_', $cond_string) . "}-" . implode('_', $languages);
if (isset($breadcrumbs_cache[$ckey])) {
$breadcrumbs = $breadcrumbs_cache[$ckey];
}
else {
$result = db_query($sql, $args);
while ($breadcrumb = db_fetch_object($result)) {
if (!isset($breadcrumb->name)) {
$breadcrumb->name = isset($info['name_constructor']) ? $info['name_constructor']($breadcrumb) : $breadcrumb->{$info}['field'];
}
$breadcrumb->breadcrumb_type = $info['type'];
$breadcrumbs[] = $breadcrumb;
}
$breadcrumbs_cache[$ckey] = $breadcrumbs;
}
}
}
return $breadcrumbs;
}