'helpers/void', 'type' => MENU_CALLBACK, 'callback' => 'void_page', 'access' => TRUE, ); } return $items; } /** * Test if a string is empty, or equals another string. If so, return a themed empty placeholder. Else return the input string. * @param $string: The string we want to find out if its empty; * @param $test: Optionally you can test against this string; In case you want to redefine "empty". */ function test_empty_string($string, $test = '') { if ($string == $test) { return theme('empty_placeholder'); } return $string; } /** * Formats a chopped off string of a certain length. Calls a theme function to * do the actual formatting. By default it will return strings in the form of * verylongstringwithsomecoo... * @param $string the original string. * @param $length Optional provide a length for the string * @param $count_addition Optional provide an amount for the additional * charachters. Giving this parameter, for example a value of 5, you will * recieve a shortened string in the form of verylongstringwithsomec..... */ function format_shorten_string($string, $length = 15, $count_addition = 3) { if (drupal_strlen($string) > $length) { $out = theme('shorten_string', drupal_substr($string, 0, ($length - $count_addition)), $string, $count_addition); } else { $out = $string; } return $out; } /** * Page functions. Render pages */ /** * Void. Render nothing. A blank page. */ function void_page() { return ''; } /** * Common API functions */ /** * Get a block as object prepared to use in the theme_block function * @param $name the modulename (block name) to get the block from. * @param $delta the blok delta. Each block in each module has a unique delta value. A number indicating that block. */ function get_block($name, $delta = 0) { if ($result = module_invoke($name, 'block', 'view', $delta)) { $block = (object)$result; $block->module = $name; $block->delta = $delta; return $block; } } /** * Find out if a user has a certain role or roles. * @param $user a user object. Must only contain the $user->roles array. * @param $roles an array of roles to check for. * @return TRUE if the user has a role you checked for, FALSE if the user is not * within any of the requested roles. */ function user_has_role($user, $roles) { foreach ($roles as $rid) { if(in_array($rid, array_keys($user->roles))) { return TRUE; } } return FALSE; } /** * Theme functions */ /** * Theme an "empty" placeholder. Outputs a translated "not available" by default. * @param $message: Optional. Provide a translated message string. * @return a string that can be used as placeholder for non existing content. */ function theme_empty_placeholder($message = NULL) { $message = ($message ? $message : t("not available")); return '' . $message .''; } /** * Return a themed list of definition items. * Patch pending at http://drupal.org/node/54898 * @param $items * An array of items to be displayed in the list. * The argument is: array("term" => $term, "definitions" => $definitions) * If you provide the $definition as arrays, you will get multiple DDs with each DT. * If you provide the $definitions as a string, only one DD will be added to the DT. * @param $title * The title of the list. * @param $filter * Boolean value to define wether or not you wish to filter the input. Should be left TRUE, unless you sanitize your input yourself. * @return * A string containing the list output. */ function theme_definition_list($items = array(), $title = NULL, $filter = TRUE) { $output = '