Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
/** * Generate the themed output. * * All requests for theme hooks must go through this function. It examines * the request and routes it to the appropriate theme function. The theme * registry is checked to determine which implementation to use, which may * be a function or a template. * * If the implementation is a function, it is executed and its return value * passed along. * * If the implementation is a template, the arguments are converted to a * $variables array. This array is then modified by the module implementing * the hook, theme engine (if applicable) and the theme. The following * functions may be used to modify the $variables array. They are processed in * this order when available: * * - template_preprocess(&$variables) * This sets a default set of variables for all template implementations. * * - template_preprocess_HOOK(&$variables) * This is the first preprocessor called specific to the hook; it should be * implemented by the module that registers it. * * - MODULE_preprocess(&$variables) * This will be called for all templates; it should only be used if there * is a real need. It's purpose is similar to template_preprocess(). * * - MODULE_preprocess_HOOK(&$variables) * This is for modules that want to alter or provide extra variables for * theming hooks not registered to itself. For example, if a module named * "foo" wanted to alter the $submitted variable for the hook "node" a * preprocess function of foo_preprocess_node() can be created to intercept * and alter the variable. * * - ENGINE_engine_preprocess(&$variables) * This function should only be implemented by theme engines and exists * so that it can set necessary variables for all hooks. * * - ENGINE_engine_preprocess_HOOK(&$variables) * This is the same as the previous function, but it is called for a single * theming hook. * * - ENGINE_preprocess(&$variables) * This is meant to be used by themes that utilize a theme engine. It is * provided so that the preprocessor is not locked into a specific theme. * This makes it easy to share and transport code but theme authors must be * careful to prevent fatal re-declaration errors when using sub-themes that * have their own preprocessor named exactly the same as it's base theme. In * the default theme engine (PHPTemplate), sub-themes will load their own * template.php file in addition to the one used for it's parent theme. This * increases the risk for these errors. A good practice is to use the engine * name for the base theme and the theme name for the sub-themes to minimize * this possibility. * * - ENGINE_preprocess_HOOK(&$variables) * The same applies from the previous function, but it is called for a * specific hook. * * - THEME_preprocess(&$variables) * These functions are based upon the raw theme; they should primarily be * used by themes that do not use an engine or by sub-themes. It serves the * same purpose as ENGINE_preprocess(). * * - THEME_preprocess_HOOK(&$variables) * The same applies from the previous function, but it is called for a * specific hook. * * There are two special variables that these hooks can set: * 'template_file' and 'template_files'. These will be merged together * to form a list of 'suggested' alternate template files to use, in * reverse order of priority. template_file will always be a higher * priority than items in template_files. theme() will then look for these * files, one at a time, and use the first one * that exists. * @param $hook * The name of the theme function to call. May be an array, in which * case the first hook that actually has an implementation registered * will be used. This can be used to choose 'fallback' theme implementations, * so that if the specific theme hook isn't implemented anywhere, a more * generic one will be used. This can allow themes to create specific theme * implementations for named objects. * @param ... * Additional arguments to pass along to the theme function. * @return * An HTML string that generates the themed output. */
From the Design Piracy series on my blog: