filename; list($tool) = explode('.', $file->name, 2); $function = 'ctools_' . $tool . '_' . $type; if (function_exists($function)) { $function($items); } } } /** * Implementation of hook_theme(). */ function ctools_theme() { $items = array(); _ctools_passthrough($items, 'theme'); return $items; } /** * Implementation of hook_menu(). */ function ctools_menu() { $items = array(); _ctools_passthrough($items, 'menu'); return $items; } /** * Implementation of hook_ctools_plugin_dierctory() to let the system know * we implement task and task_handler plugins. */ function ctools_ctools_plugin_directory($module, $plugin) { if ($module == 'ctools') { return 'plugins/' . $plugin; } } /** * Get a list of roles in the system. */ function ctools_get_roles() { static $roles = NULL; if (!isset($roles)) { $roles = array(); $result = db_query("SELECT r.rid, r.name FROM {role} r ORDER BY r.name"); while ($obj = db_fetch_object($result)) { $roles[$obj->rid] = $obj->name; } } return $roles; } /** * Determine if the current user has access via a plugin. * * This function is meant to be embedded in the Drupal menu system, and * therefore is in the .module file since sub files can't be loaded, and * takes arguments a little bit more haphazardly than ctools_access(). * * @param $access * An access control array which contains the following information: * - 'logic': and or or. Whether all tests must pass or one must pass. * - 'plugins': An array of access plugins. Each contains: * - - 'name': The name of the plugin * - - 'settings': The settings from the plugin UI. * - - 'context': Which context to use. * @param ... * zero or more context arguments generated from argument plugins. These * contexts must have an 'id' attached to them so that they can be * properly associated. The argument plugin system should set this, but * if the context is coming from elsewhere it will need to be set manually. * * @return * TRUE if access is granted, false if otherwise. */ function ctools_access_menu($access) { // Short circuit everything if there are no access tests. if (empty($access['plugins'])) { return TRUE; } $contexts = array(); foreach (func_get_args() as $arg) { if (is_object($arg) && get_class($arg) == 'ctools_context') { $contexts[$arg->id] = $arg; } } ctools_include('context'); return ctools_access($access, $contexts); } /** * Implementation of hook_cron. Clean up old caches. */ function ctools_cron() { if (variable_get('ctools_last_cron', 0) < time() - 86400) { variable_set('ctools_last_cron', time()); ctools_include('object-cache'); ctools_object_cache_clean(); } } /* * Break x,y,z and x+y+z into an array. Numeric only. * * @param $str * The string to parse. * * @return $object * An object containing * - operator: Either 'and' or 'or' * - value: An array of numeric values. */ function ctools_break_phrase($str) { $object = new stdClass(); if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str)) { // The '+' character in a query string may be parsed as ' '. $object->operator = 'or'; $object->value = preg_split('/[+ ]/', $str); } else if (preg_match('/^([0-9]+,)*[0-9]+$/', $str)) { $object->operator = 'and'; $object->value = explode(',', $str); } // Keep an 'error' value if invalid strings were given. if (!empty($str) && (empty($object->value) || !is_array($object->value))) { $object->value = array(-1); $object->invalid_input = TRUE; return $object; } // Doubly ensure that all values are numeric only. foreach ($object->value as $id => $value) { $object->value[$id] = intval($value); } return $object; } /** * A theme preprocess function to automatically allow panels-based node * templates based upon input when the panel was configured. */ function ctools_preprocess_node(&$vars) { // The 'panel_identifier' attribute of the node is added when the pane is // rendered. if (!empty($vars['node']->panel_identifier)) { $vars['panel_identifier'] = check_plain($vars['node']->panel_identifier); $vars['template_files'][] = 'node-panel-' . check_plain($vars['node']->panel_identifier); } }