1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016 |
- <?php
- define('MARK_READ', 0);
- define('MARK_NEW', 1);
- define('MARK_UPDATED', 2);
- function drupal_theme_access($theme) {
- if (is_object($theme)) {
- return _drupal_theme_access($theme);
- }
- else {
- $themes = list_themes();
- return isset($themes[$theme]) && _drupal_theme_access($themes[$theme]);
- }
- }
- function _drupal_theme_access($theme) {
- $admin_theme = variable_get('admin_theme');
- return !empty($theme->status) || ($admin_theme && $theme->name == $admin_theme);
- }
- function drupal_theme_initialize() {
- global $theme, $user, $theme_key;
-
- if (isset($theme)) {
- return;
- }
- drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);
- $themes = list_themes();
-
-
- $theme = !empty($user->theme) && drupal_theme_access($user->theme) ? $user->theme : variable_get('theme_default', 'bartik');
-
-
- $custom_theme = menu_get_custom_theme();
- $theme = !empty($custom_theme) ? $custom_theme : $theme;
-
- $theme_key = $theme;
-
- $base_theme = array();
- $ancestor = $theme;
- while ($ancestor && isset($themes[$ancestor]->base_theme)) {
- $ancestor = $themes[$ancestor]->base_theme;
- $base_theme[] = $themes[$ancestor];
- }
- _drupal_theme_initialize($themes[$theme], array_reverse($base_theme));
-
- drupal_static_reset('drupal_alter');
-
-
-
- $setting['ajaxPageState'] = array(
- 'theme' => $theme_key,
- 'theme_token' => drupal_get_token($theme_key),
- );
- drupal_add_js($setting, 'setting');
- }
- function _drupal_theme_initialize($theme, $base_theme = array(), $registry_callback = '_theme_load_registry') {
- global $theme_info, $base_theme_info, $theme_engine, $theme_path;
- $theme_info = $theme;
- $base_theme_info = $base_theme;
- $theme_path = dirname($theme->filename);
-
-
-
- $final_stylesheets = array();
-
- foreach ($base_theme as $base) {
- if (!empty($base->stylesheets)) {
- foreach ($base->stylesheets as $media => $stylesheets) {
- foreach ($stylesheets as $name => $stylesheet) {
- $final_stylesheets[$media][$name] = $stylesheet;
- }
- }
- }
- }
-
- if (!empty($theme->stylesheets)) {
- foreach ($theme->stylesheets as $media => $stylesheets) {
- foreach ($stylesheets as $name => $stylesheet) {
- $final_stylesheets[$media][$name] = $stylesheet;
- }
- }
- }
-
- foreach ($final_stylesheets as $media => $stylesheets) {
- foreach ($stylesheets as $stylesheet) {
- drupal_add_css($stylesheet, array('group' => CSS_THEME, 'every_page' => TRUE, 'media' => $media));
- }
- }
-
- $final_scripts = array();
-
- foreach ($base_theme as $base) {
- if (!empty($base->scripts)) {
- foreach ($base->scripts as $name => $script) {
- $final_scripts[$name] = $script;
- }
- }
- }
-
- if (!empty($theme->scripts)) {
- foreach ($theme->scripts as $name => $script) {
- $final_scripts[$name] = $script;
- }
- }
-
- foreach ($final_scripts as $script) {
- drupal_add_js($script, array('group' => JS_THEME, 'every_page' => TRUE));
- }
- $theme_engine = NULL;
-
- if (isset($theme->engine)) {
-
- include_once DRUPAL_ROOT . '/' . $theme->owner;
- $theme_engine = $theme->engine;
- if (function_exists($theme_engine . '_init')) {
- foreach ($base_theme as $base) {
- call_user_func($theme_engine . '_init', $base);
- }
- call_user_func($theme_engine . '_init', $theme);
- }
- }
- else {
-
- foreach ($base_theme as $base) {
-
- if (!empty($base->owner)) {
- include_once DRUPAL_ROOT . '/' . $base->owner;
- }
- }
-
- if (!empty($theme->owner)) {
- include_once DRUPAL_ROOT . '/' . $theme->owner;
- }
- }
- if (isset($registry_callback)) {
- _theme_registry_callback($registry_callback, array($theme, $base_theme, $theme_engine));
- }
- }
- function theme_get_registry($complete = TRUE) {
-
- static $drupal_static_fast;
- if (!isset($drupal_static_fast)) {
- $drupal_static_fast['registry'] = &drupal_static('theme_get_registry');
- }
- $theme_registry = &$drupal_static_fast['registry'];
-
-
- if (!is_array($theme_registry)) {
- drupal_theme_initialize();
- $theme_registry = array();
- }
- $key = (int) $complete;
- if (!isset($theme_registry[$key])) {
- list($callback, $arguments) = _theme_registry_callback();
- if (!$complete) {
- $arguments[] = FALSE;
- }
- $theme_registry[$key] = call_user_func_array($callback, $arguments);
- }
- return $theme_registry[$key];
- }
- function _theme_registry_callback($callback = NULL, array $arguments = array()) {
- static $stored;
- if (isset($callback)) {
- $stored = array($callback, $arguments);
- }
- return $stored;
- }
- function _theme_load_registry($theme, $base_theme = NULL, $theme_engine = NULL, $complete = TRUE) {
- if ($complete) {
-
- $cached = cache_get("theme_registry:$theme->name");
- if (isset($cached->data)) {
- $registry = $cached->data;
- }
- else {
-
- $registry = _theme_build_registry($theme, $base_theme, $theme_engine);
-
-
- if (module_load_all(NULL)) {
- _theme_save_registry($theme, $registry);
- }
- }
- return $registry;
- }
- else {
- return new ThemeRegistry('theme_registry:runtime:' . $theme->name, 'cache');
- }
- }
- function _theme_save_registry($theme, $registry) {
- cache_set("theme_registry:$theme->name", $registry);
- }
- function drupal_theme_rebuild() {
- drupal_static_reset('theme_get_registry');
- cache_clear_all('theme_registry', 'cache', TRUE);
- }
- class ThemeRegistry Extends DrupalCacheArray {
-
- protected $persistable;
-
- protected $completeRegistry;
- function __construct($cid, $bin) {
- $this->cid = $cid;
- $this->bin = $bin;
- $this->persistable = module_load_all(NULL) && $_SERVER['REQUEST_METHOD'] == 'GET';
- $data = array();
- if ($this->persistable && $cached = cache_get($this->cid, $this->bin)) {
- $data = $cached->data;
- }
- else {
-
-
-
-
- $data = $this->initializeRegistry();
- if ($this->persistable) {
- $this->set($data);
- }
- }
- $this->storage = $data;
- }
-
- function initializeRegistry() {
- $this->completeRegistry = theme_get_registry();
- return array_fill_keys(array_keys($this->completeRegistry), NULL);
- }
- public function offsetExists($offset) {
-
-
-
-
- return array_key_exists($offset, $this->storage);
- }
- public function offsetGet($offset) {
-
-
-
- if (isset($this->storage[$offset])) {
- return $this->storage[$offset];
- }
- elseif (array_key_exists($offset, $this->storage)) {
- return $this->resolveCacheMiss($offset);
- }
- }
- public function resolveCacheMiss($offset) {
- if (!isset($this->completeRegistry)) {
- $this->completeRegistry = theme_get_registry();
- }
- $this->storage[$offset] = $this->completeRegistry[$offset];
- if ($this->persistable) {
- $this->persist($offset);
- }
- return $this->storage[$offset];
- }
- public function set($data, $lock = TRUE) {
- $lock_name = $this->cid . ':' . $this->bin;
- if (!$lock || lock_acquire($lock_name)) {
- if ($cached = cache_get($this->cid, $this->bin)) {
-
-
- $data = array_merge($cached->data, $data);
- }
- else {
- $registry = $this->initializeRegistry();
- $data = array_merge($registry, $data);
- }
- cache_set($this->cid, $data, $this->bin);
- if ($lock) {
- lock_release($lock_name);
- }
- }
- }
- }
- function _theme_process_registry(&$cache, $name, $type, $theme, $path) {
- $result = array();
-
-
- $variable_process_phases = array(
- 'preprocess functions' => 'preprocess',
- 'process functions' => 'process',
- );
- $hook_defaults = array(
- 'variables' => TRUE,
- 'render element' => TRUE,
- 'pattern' => TRUE,
- 'base hook' => TRUE,
- );
-
-
- $function = $name . '_theme';
- if (function_exists($function)) {
- $result = $function($cache, $type, $theme, $path);
- foreach ($result as $hook => $info) {
-
-
-
-
-
-
- $result[$hook]['type'] = $type;
- $result[$hook]['theme path'] = $path;
-
-
- if (!isset($info['template']) && !isset($info['function'])) {
- $result[$hook]['function'] = ($type == 'module' ? 'theme_' : $name . '_') . $hook;
- }
- if (isset($cache[$hook]['includes'])) {
- $result[$hook]['includes'] = $cache[$hook]['includes'];
- }
-
-
-
-
- if (isset($info['file'])) {
- $include_file = isset($info['path']) ? $info['path'] : $path;
- $include_file .= '/' . $info['file'];
- include_once DRUPAL_ROOT . '/' . $include_file;
- $result[$hook]['includes'][] = $include_file;
- }
-
-
- if (isset($cache[$hook])) {
- $result[$hook] += array_intersect_key($cache[$hook], $hook_defaults);
- }
-
- if (isset($info['template'])) {
-
- if (!isset($info['path'])) {
- $result[$hook]['template'] = $path . '/' . $info['template'];
- }
- }
-
-
- foreach ($variable_process_phases as $phase_key => $phase) {
-
- if (!isset($info[$phase_key]) || !is_array($info[$phase_key])) {
- $info[$phase_key] = array();
- $prefixes = array();
- if ($type == 'module') {
-
- $prefixes[] = 'template';
-
-
-
- $prefixes += module_list();
- }
- elseif ($type == 'theme_engine' || $type == 'base_theme_engine') {
-
-
- $prefixes[] = $name . '_engine';
-
-
- $prefixes[] = $theme;
- }
- else {
-
-
- $prefixes[] = $name;
- }
- foreach ($prefixes as $prefix) {
-
-
- if (isset($info['template']) && function_exists($prefix . '_' . $phase)) {
- $info[$phase_key][] = $prefix . '_' . $phase;
- }
- if (function_exists($prefix . '_' . $phase . '_' . $hook)) {
- $info[$phase_key][] = $prefix . '_' . $phase . '_' . $hook;
- }
- }
- }
-
-
-
- if (!empty($info['override ' . $phase_key])) {
-
- unset($result[$hook]['override ' . $phase_key]);
- }
- elseif (isset($cache[$hook][$phase_key]) && is_array($cache[$hook][$phase_key])) {
- $info[$phase_key] = array_merge($cache[$hook][$phase_key], $info[$phase_key]);
- }
- $result[$hook][$phase_key] = $info[$phase_key];
- }
- }
-
- $cache = $result + $cache;
- }
-
-
- if ($type == 'theme' || $type == 'base_theme') {
- foreach ($cache as $hook => $info) {
-
- if (empty($result[$hook])) {
- foreach ($variable_process_phases as $phase_key => $phase) {
- if (!isset($info[$phase_key])) {
- $cache[$hook][$phase_key] = array();
- }
-
-
- if (isset($info['template']) && function_exists($name . '_' . $phase)) {
- $cache[$hook][$phase_key][] = $name . '_' . $phase;
- }
- if (function_exists($name . '_' . $phase . '_' . $hook)) {
- $cache[$hook][$phase_key][] = $name . '_' . $phase . '_' . $hook;
- $cache[$hook]['theme path'] = $path;
- }
-
- $cache[$hook][$phase_key] = array_unique($cache[$hook][$phase_key]);
- }
- }
- }
- }
- }
- function _theme_build_registry($theme, $base_theme, $theme_engine) {
- $cache = array();
-
-
-
-
- if ($cached = cache_get('theme_registry:build:modules')) {
- $cache = $cached->data;
- }
- else {
- foreach (module_implements('theme') as $module) {
- _theme_process_registry($cache, $module, 'module', $module, drupal_get_path('module', $module));
- }
-
- if (module_load_all(NULL)) {
- cache_set('theme_registry:build:modules', $cache);
- }
- }
-
- foreach ($base_theme as $base) {
-
- $base_path = dirname($base->filename);
- if ($theme_engine) {
- _theme_process_registry($cache, $theme_engine, 'base_theme_engine', $base->name, $base_path);
- }
- _theme_process_registry($cache, $base->name, 'base_theme', $base->name, $base_path);
- }
-
- if ($theme_engine) {
- _theme_process_registry($cache, $theme_engine, 'theme_engine', $theme->name, dirname($theme->filename));
- }
-
- _theme_process_registry($cache, $theme->name, 'theme', $theme->name, dirname($theme->filename));
-
- drupal_alter('theme_registry', $cache);
-
- foreach ($cache as $hook => $info) {
- foreach (array('preprocess functions', 'process functions') as $phase) {
- if (empty($info[$phase])) {
- unset($cache[$hook][$phase]);
- }
- }
- }
- return $cache;
- }
- function list_themes($refresh = FALSE) {
- $list = &drupal_static(__FUNCTION__, array());
- if ($refresh) {
- $list = array();
- system_list_reset();
- }
- if (empty($list)) {
- $list = array();
- $themes = array();
-
-
- if (!defined('MAINTENANCE_MODE')) {
- try {
- $themes = system_list('theme');
- }
- catch (Exception $e) {
-
- $themes = _system_rebuild_theme_data();
- }
- }
- else {
-
- $themes = _system_rebuild_theme_data();
- }
- foreach ($themes as $theme) {
- foreach ($theme->info['stylesheets'] as $media => $stylesheets) {
- foreach ($stylesheets as $stylesheet => $path) {
- $theme->stylesheets[$media][$stylesheet] = $path;
- }
- }
- foreach ($theme->info['scripts'] as $script => $path) {
- $theme->scripts[$script] = $path;
- }
- if (isset($theme->info['engine'])) {
- $theme->engine = $theme->info['engine'];
- }
- if (isset($theme->info['base theme'])) {
- $theme->base_theme = $theme->info['base theme'];
- }
-
-
- if (!isset($theme->status)) {
- $theme->status = 0;
- }
- $list[$theme->name] = $theme;
- }
- }
- return $list;
- }
- function drupal_find_base_themes($themes, $key, $used_keys = array()) {
- $base_key = $themes[$key]->info['base theme'];
-
- if (!isset($themes[$base_key])) {
- return array($base_key => NULL);
- }
- $current_base_theme = array($base_key => $themes[$base_key]->info['name']);
-
- if (isset($themes[$base_key]->info['base theme'])) {
-
- if (isset($themes[$base_key]->base_themes)) {
- return $themes[$base_key]->base_themes + $current_base_theme;
- }
-
- if (!empty($used_keys[$base_key])) {
- return array($base_key => NULL);
- }
- $used_keys[$base_key] = TRUE;
- return drupal_find_base_themes($themes, $base_key, $used_keys) + $current_base_theme;
- }
-
- return $current_base_theme;
- }
- function theme($hook, $variables = array()) {
-
-
-
- if (!module_load_all(NULL) && !defined('MAINTENANCE_MODE')) {
- throw new Exception(t('theme() may not be called until all modules are loaded.'));
- }
- $hooks = theme_get_registry(FALSE);
-
-
- if (is_array($hook)) {
- foreach ($hook as $candidate) {
- if (isset($hooks[$candidate])) {
- break;
- }
- }
- $hook = $candidate;
- }
- $theme_hook_original = $hook;
-
-
- if (!isset($hooks[$hook])) {
-
-
- while ($pos = strrpos($hook, '__')) {
- $hook = substr($hook, 0, $pos);
- if (isset($hooks[$hook])) {
- break;
- }
- }
- if (!isset($hooks[$hook])) {
-
-
- if (!isset($candidate)) {
- watchdog('theme', 'Theme hook %hook not found.', array('%hook' => $hook), WATCHDOG_WARNING);
- }
- return '';
- }
- }
- $info = $hooks[$hook];
- global $theme_path;
- $temp = $theme_path;
-
- $theme_path = $info['theme path'];
-
-
- if (!empty($info['includes'])) {
- foreach ($info['includes'] as $include_file) {
- include_once DRUPAL_ROOT . '/' . $include_file;
- }
- }
-
-
- if (isset($variables['#theme']) || isset($variables['#theme_wrappers'])) {
- $element = $variables;
- $variables = array();
- if (isset($info['variables'])) {
- foreach (array_keys($info['variables']) as $name) {
- if (isset($element["#$name"])) {
- $variables[$name] = $element["#$name"];
- }
- }
- }
- else {
- $variables[$info['render element']] = $element;
- }
- }
-
- if (!empty($info['variables'])) {
- $variables += $info['variables'];
- }
- elseif (!empty($info['render element'])) {
- $variables += array($info['render element'] => array());
- }
- $variables['theme_hook_original'] = $theme_hook_original;
-
-
-
-
-
- if (isset($info['base hook'])) {
- $base_hook = $info['base hook'];
- $base_hook_info = $hooks[$base_hook];
-
-
- if (!empty($base_hook_info['includes'])) {
- foreach ($base_hook_info['includes'] as $include_file) {
- include_once DRUPAL_ROOT . '/' . $include_file;
- }
- }
- if (isset($base_hook_info['preprocess functions']) || isset($base_hook_info['process functions'])) {
- $variables['theme_hook_suggestion'] = $hook;
- $hook = $base_hook;
- $info = $base_hook_info;
- }
- }
- if (isset($info['preprocess functions']) || isset($info['process functions'])) {
- $variables['theme_hook_suggestions'] = array();
- foreach (array('preprocess functions', 'process functions') as $phase) {
- if (!empty($info[$phase])) {
- foreach ($info[$phase] as $processor_function) {
- if (function_exists($processor_function)) {
-
- $hook_clone = $hook;
- $processor_function($variables, $hook_clone);
- }
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
- $suggestions = array();
- if (!empty($variables['theme_hook_suggestions'])) {
- $suggestions = $variables['theme_hook_suggestions'];
- }
- if (!empty($variables['theme_hook_suggestion'])) {
- $suggestions[] = $variables['theme_hook_suggestion'];
- }
- foreach (array_reverse($suggestions) as $suggestion) {
- if (isset($hooks[$suggestion])) {
- $info = $hooks[$suggestion];
- break;
- }
- }
- }
-
- $output = '';
- if (isset($info['function'])) {
- if (function_exists($info['function'])) {
- $output = $info['function']($variables);
- }
- }
- else {
-
- $render_function = 'theme_render_template';
- $extension = '.tpl.php';
-
- global $theme_engine;
- if (isset($theme_engine)) {
- if ($info['type'] != 'module') {
- if (function_exists($theme_engine . '_render_template')) {
- $render_function = $theme_engine . '_render_template';
- }
- $extension_function = $theme_engine . '_extension';
- if (function_exists($extension_function)) {
- $extension = $extension_function();
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
- if (!isset($variables['directory'])) {
- $default_template_variables = array();
- template_preprocess($default_template_variables, $hook);
- $variables += $default_template_variables;
- }
-
- $template_file = $info['template'] . $extension;
- if (isset($info['path'])) {
- $template_file = $info['path'] . '/' . $template_file;
- }
- if (variable_get('theme_debug', FALSE)) {
- $output = _theme_render_template_debug($render_function, $template_file, $variables, $extension);
- }
- else {
- $output = $render_function($template_file, $variables);
- }
- }
-
- $theme_path = $temp;
- return $output;
- }
- function path_to_theme() {
- global $theme_path;
- if (!isset($theme_path)) {
- drupal_theme_initialize();
- }
- return $theme_path;
- }
- function drupal_find_theme_functions($cache, $prefixes) {
- $implementations = array();
- $functions = get_defined_functions();
- $theme_functions = preg_grep('/^(' . implode(')|(', $prefixes) . ')_/', $functions['user']);
- foreach ($cache as $hook => $info) {
- foreach ($prefixes as $prefix) {
-
-
-
-
-
-
-
-
-
-
-
- $pattern = isset($info['pattern']) ? $info['pattern'] : ($hook . '__');
- if (!isset($info['base hook']) && !empty($pattern)) {
- $matches = preg_grep('/^' . $prefix . '_' . $pattern . '/', $theme_functions);
- if ($matches) {
- foreach ($matches as $match) {
- $new_hook = substr($match, strlen($prefix) + 1);
- $arg_name = isset($info['variables']) ? 'variables' : 'render element';
- $implementations[$new_hook] = array(
- 'function' => $match,
- $arg_name => $info[$arg_name],
- 'base hook' => $hook,
- );
- }
- }
- }
-
-
-
- if (function_exists($prefix . '_' . $hook)) {
- $implementations[$hook] = array(
- 'function' => $prefix . '_' . $hook,
- );
- }
- }
- }
- return $implementations;
- }
- function drupal_find_theme_templates($cache, $extension, $path) {
- $implementations = array();
-
-
-
- $theme_paths = array();
- foreach (list_themes() as $theme_info) {
- if (!empty($theme_info->base_theme)) {
- $theme_paths[$theme_info->base_theme][$theme_info->name] = dirname($theme_info->filename);
- }
- }
- foreach ($theme_paths as $basetheme => $subthemes) {
- foreach ($subthemes as $subtheme => $subtheme_path) {
- if (isset($theme_paths[$subtheme])) {
- $theme_paths[$basetheme] = array_merge($theme_paths[$basetheme], $theme_paths[$subtheme]);
- }
- }
- }
- global $theme;
- $subtheme_paths = isset($theme_paths[$theme]) ? $theme_paths[$theme] : array();
-
- $regex = '/' . str_replace('.', '\.', $extension) . '$/';
-
- $files = drupal_system_listing($regex, $path, 'name', 0);
-
-
-
- foreach ($files as $template => $file) {
-
- if (strpos($file->uri, str_replace($subtheme_paths, '', $file->uri)) !== 0) {
- continue;
- }
-
-
-
- if (($pos = strpos($template, '.')) !== FALSE) {
- $template = substr($template, 0, $pos);
- }
-
-
- $hook = strtr($template, '-', '_');
- if (isset($cache[$hook])) {
- $implementations[$hook] = array(
- 'template' => $template,
- 'path' => dirname($file->uri),
- );
- }
- }
-
-
-
-
- $patterns = array_keys($files);
- foreach ($cache as $hook => $info) {
- $pattern = isset($info['pattern']) ? $info['pattern'] : ($hook . '__');
- if (!isset($info['base hook']) && !empty($pattern)) {
-
-
- $pattern = strtr($pattern, '_', '-');
- $matches = preg_grep('/^' . $pattern . '/', $patterns);
- if ($matches) {
- foreach ($matches as $match) {
- $file = substr($match, 0, strpos($match, '.'));
-
-
- $arg_name = isset($info['variables']) ? 'variables' : 'render element';
- $implementations[strtr($file, '-', '_')] = array(
- 'template' => $file,
- 'path' => dirname($files[$match]->uri),
- $arg_name => $info[$arg_name],
- 'base hook' => $hook,
- );
- }
- }
- }
- }
- return $implementations;
- }
- function theme_get_setting($setting_name, $theme = NULL) {
- $cache = &drupal_static(__FUNCTION__, array());
-
- if (!isset($theme)) {
- $theme = !empty($GLOBALS['theme_key']) ? $GLOBALS['theme_key'] : '';
- }
- if (empty($cache[$theme])) {
-
-
-
- $cache[$theme] = array(
- 'default_logo' => 1,
- 'logo_path' => '',
- 'default_favicon' => 1,
- 'favicon_path' => '',
-
- 'favicon_mimetype' => 'image/vnd.microsoft.icon',
- );
-
- $features = _system_default_theme_features();
- foreach ($features as $feature) {
- $cache[$theme]['toggle_' . $feature] = 1;
- }
-
-
- if ($theme) {
- $themes = list_themes();
- $theme_object = $themes[$theme];
-
- if (isset($theme_object->base_themes)) {
- $theme_keys = array_keys($theme_object->base_themes);
- $theme_keys[] = $theme;
- }
- else {
- $theme_keys = array($theme);
- }
- foreach ($theme_keys as $theme_key) {
- if (!empty($themes[$theme_key]->info['settings'])) {
- $cache[$theme] = array_merge($cache[$theme], $themes[$theme_key]->info['settings']);
- }
- }
- }
-
- $cache[$theme] = array_merge($cache[$theme], variable_get('theme_settings', array()));
- if ($theme) {
-
- $cache[$theme] = array_merge($cache[$theme], variable_get('theme_' . $theme . '_settings', array()));
-
-
- if (!empty($theme_object->info['features'])) {
- foreach ($features as $feature) {
- if (!in_array($feature, $theme_object->info['features'])) {
- $cache[$theme]['toggle_' . $feature] = NULL;
- }
- }
- }
-
- if ($cache[$theme]['toggle_logo']) {
- if ($cache[$theme]['default_logo']) {
- $cache[$theme]['logo'] = file_create_url(dirname($theme_object->filename) . '/logo.png');
- }
- elseif ($cache[$theme]['logo_path']) {
- $cache[$theme]['logo'] = file_create_url($cache[$theme]['logo_path']);
- }
- }
-
- if ($cache[$theme]['toggle_favicon']) {
- if ($cache[$theme]['default_favicon']) {
- if (file_exists($favicon = dirname($theme_object->filename) . '/favicon.ico')) {
- $cache[$theme]['favicon'] = file_create_url($favicon);
- }
- else {
- $cache[$theme]['favicon'] = file_create_url('misc/favicon.ico');
- }
- }
- elseif ($cache[$theme]['favicon_path']) {
- $cache[$theme]['favicon'] = file_create_url($cache[$theme]['favicon_path']);
- }
- else {
- $cache[$theme]['toggle_favicon'] = FALSE;
- }
- }
- }
- }
- return isset($cache[$theme][$setting_name]) ? $cache[$theme][$setting_name] : NULL;
- }
- function theme_render_template($template_file, $variables) {
-
- extract($variables, EXTR_SKIP);
-
- ob_start();
-
- include DRUPAL_ROOT . '/' . $template_file;
-
- return ob_get_clean();
- }
- function _theme_render_template_debug($template_function, $template_file, $variables, $extension) {
- $output = array(
- 'debug_prefix' => '',
- 'debug_info' => '',
- 'rendered_markup' => call_user_func($template_function, $template_file, $variables),
- 'debug_suffix' => '',
- );
- $output['debug_prefix'] .= "\n\n<!-- THEME DEBUG -->";
- $output['debug_prefix'] .= "\n<!-- CALL: theme('" . check_plain($variables['theme_hook_original']) . "') -->";
-
-
- if (!empty($variables['theme_hook_suggestions'])) {
- $variables['theme_hook_suggestions'] = array_reverse($variables['theme_hook_suggestions']);
- }
-
-
- if (strpos($variables['theme_hook_original'], '__') !== FALSE) {
- $derived_suggestions[] = $hook = $variables['theme_hook_original'];
- while ($pos = strrpos($hook, '__')) {
- $hook = substr($hook, 0, $pos);
- $derived_suggestions[] = $hook;
- }
-
-
- $base_hook = array_pop($derived_suggestions);
- $variables['theme_hook_suggestions'] = array_merge($derived_suggestions, $variables['theme_hook_suggestions']);
- $variables['theme_hook_suggestions'][] = $base_hook;
- }
- if (!empty($variables['theme_hook_suggestions'])) {
- $current_template = basename($template_file);
- $suggestions = $variables['theme_hook_suggestions'];
-
-
- if (strpos($variables['theme_hook_original'], '__') === FALSE) {
- $suggestions[] = $variables['theme_hook_original'];
- }
- foreach ($suggestions as &$suggestion) {
- $template = strtr($suggestion, '_', '-') . $extension;
- $prefix = ($template == $current_template) ? 'x' : '*';
- $suggestion = $prefix . ' ' . $template;
- }
- $output['debug_info'] .= "\n<!-- FILE NAME SUGGESTIONS:\n " . check_plain(implode("\n ", $suggestions)) . "\n-->";
- }
- $output['debug_info'] .= "\n<!-- BEGIN OUTPUT from '" . check_plain($template_file) . "' -->\n";
- $output['debug_suffix'] .= "\n<!-- END OUTPUT from '" . check_plain($template_file) . "' -->\n\n";
- return implode('', $output);
- }
- function theme_enable($theme_list) {
- drupal_clear_css_cache();
- foreach ($theme_list as $key) {
- db_update('system')
- ->fields(array('status' => 1))
- ->condition('type', 'theme')
- ->condition('name', $key)
- ->execute();
- }
- list_themes(TRUE);
- menu_rebuild();
- drupal_theme_rebuild();
-
- module_invoke_all('themes_enabled', $theme_list);
- }
- function theme_disable($theme_list) {
-
- if ($pos = array_search(variable_get('theme_default', 'bartik'), $theme_list) !== FALSE) {
- unset($theme_list[$pos]);
- if (empty($theme_list)) {
- return;
- }
- }
- drupal_clear_css_cache();
- foreach ($theme_list as $key) {
- db_update('system')
- ->fields(array('status' => 0))
- ->condition('type', 'theme')
- ->condition('name', $key)
- ->execute();
- }
- list_themes(TRUE);
- menu_rebuild();
- drupal_theme_rebuild();
-
- module_invoke_all('themes_disabled', $theme_list);
- }
- function theme_status_messages($variables) {
- $display = $variables['display'];
- $output = '';
- $status_heading = array(
- 'status' => t('Status message'),
- 'error' => t('Error message'),
- 'warning' => t('Warning message'),
- );
- foreach (drupal_get_messages($display) as $type => $messages) {
- $output .= "<div class=\"messages $type\">\n";
- if (!empty($status_heading[$type])) {
- $output .= '<h2 class="element-invisible">' . $status_heading[$type] . "</h2>\n";
- }
- if (count($messages) > 1) {
- $output .= " <ul>\n";
- foreach ($messages as $message) {
- $output .= ' <li>' . $message . "</li>\n";
- }
- $output .= " </ul>\n";
- }
- else {
- $output .= reset($messages);
- }
- $output .= "</div>\n";
- }
- return $output;
- }
- function theme_link($variables) {
- return '<a href="' . check_plain(url($variables['path'], $variables['options'])) . '"' . drupal_attributes($variables['options']['attributes']) . '>' . ($variables['options']['html'] ? $variables['text'] : check_plain($variables['text'])) . '</a>';
- }
- function theme_links($variables) {
- $links = (array) $variables['links'];
- $attributes = (array) $variables['attributes'];
- $heading = $variables['heading'];
- global $language_url;
- $output = '';
- if (!empty($links)) {
-
-
- if (!empty($heading)) {
- if (is_string($heading)) {
-
-
- $heading = array(
- 'text' => $heading,
-
- 'level' => 'h2',
- );
- }
- $output .= '<' . $heading['level'];
- if (!empty($heading['class'])) {
- $output .= drupal_attributes(array('class' => $heading['class']));
- }
- $output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>';
- }
- $output .= '<ul' . drupal_attributes($attributes) . '>';
- $num_links = count($links);
- $i = 1;
- foreach ($links as $key => $link) {
- $class = array($key);
-
-
- if ($i == 1) {
- $class[] = 'first';
- }
- if ($i == $num_links) {
- $class[] = 'last';
- }
- if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))
- && (empty($link['language']) || $link['language']->language == $language_url->language)) {
- $class[] = 'active';
- }
- $output .= '<li' . drupal_attributes(array('class' => $class)) . '>';
- if (isset($link['href'])) {
-
- $output .= l($link['title'], $link['href'], $link);
- }
- elseif (!empty($link['title'])) {
-
-
- if (empty($link['html'])) {
- $link['title'] = check_plain($link['title']);
- }
- $span_attributes = '';
- if (isset($link['attributes'])) {
- $span_attributes = drupal_attributes($link['attributes']);
- }
- $output .= '<span' . $span_attributes . '>' . $link['title'] . '</span>';
- }
- $i++;
- $output .= "</li>\n";
- }
- $output .= '</ul>';
- }
- return $output;
- }
- function theme_image($variables) {
- $attributes = $variables['attributes'];
- $attributes['src'] = file_create_url($variables['path']);
- foreach (array('width', 'height', 'alt', 'title') as $key) {
- if (isset($variables[$key])) {
- $attributes[$key] = $variables[$key];
- }
- }
- return '<img' . drupal_attributes($attributes) . ' />';
- }
- function theme_breadcrumb($variables) {
- $breadcrumb = $variables['breadcrumb'];
- if (!empty($breadcrumb)) {
-
-
- $output = '<h2 class="element-invisible">' . t('You are here') . '</h2>';
- $output .= '<div class="breadcrumb">' . implode(' » ', $breadcrumb) . '</div>';
- return $output;
- }
- }
- function theme_table($variables) {
- $header = $variables['header'];
- $rows = $variables['rows'];
- $attributes = $variables['attributes'];
- $caption = $variables['caption'];
- $colgroups = $variables['colgroups'];
- $sticky = $variables['sticky'];
- $empty = $variables['empty'];
-
- if (!empty($header) && $sticky) {
- drupal_add_js('misc/tableheader.js');
-
-
- $attributes['class'][] = 'sticky-enabled';
- }
- $output = '<table' . drupal_attributes($attributes) . ">\n";
- if (isset($caption)) {
- $output .= '<caption>' . $caption . "</caption>\n";
- }
-
- if (!empty($colgroups)) {
- foreach ($colgroups as $number => $colgroup) {
- $attributes = array();
-
- if (isset($colgroup['data'])) {
- foreach ($colgroup as $key => $value) {
- if ($key == 'data') {
- $cols = $value;
- }
- else {
- $attributes[$key] = $value;
- }
- }
- }
- else {
- $cols = $colgroup;
- }
-
- if (is_array($cols) && count($cols)) {
- $output .= ' <colgroup' . drupal_attributes($attributes) . '>';
- $i = 0;
- foreach ($cols as $col) {
- $output .= ' <col' . drupal_attributes($col) . ' />';
- }
- $output .= " </colgroup>\n";
- }
- else {
- $output .= ' <colgroup' . drupal_attributes($attributes) . " />\n";
- }
- }
- }
-
- if (empty($rows) && $empty) {
- $header_count = 0;
- if (!empty($header)) {
- foreach ($header as $header_cell) {
- if (is_array($header_cell)) {
- $header_count += isset($header_cell['colspan']) ? $header_cell['colspan'] : 1;
- }
- else {
- $header_count++;
- }
- }
- }
- $rows[] = array(array('data' => $empty, 'colspan' => $header_count, 'class' => array('empty', 'message')));
- }
-
- if (!empty($header)) {
- $ts = tablesort_init($header);
-
-
- $output .= (!empty($rows) ? ' <thead><tr>' : ' <tr>');
- foreach ($header as $cell) {
- $cell = tablesort_header($cell, $header, $ts);
- $output .= _theme_table_cell($cell, TRUE);
- }
-
- $output .= (!empty($rows) ? " </tr></thead>\n" : "</tr>\n");
- }
- else {
- $ts = array();
- }
-
- if (!empty($rows)) {
- $output .= "<tbody>\n";
- $flip = array('even' => 'odd', 'odd' => 'even');
- $class = 'even';
- foreach ($rows as $number => $row) {
-
- if (isset($row['data'])) {
- $cells = $row['data'];
- $no_striping = isset($row['no_striping']) ? $row['no_striping'] : FALSE;
-
- $attributes = $row;
- unset($attributes['data']);
- unset($attributes['no_striping']);
- }
- else {
- $cells = $row;
- $attributes = array();
- $no_striping = FALSE;
- }
- if (!empty($cells)) {
-
- if (!$no_striping) {
- $class = $flip[$class];
- $attributes['class'][] = $class;
- }
-
- $output .= ' <tr' . drupal_attributes($attributes) . '>';
- $i = 0;
- foreach ($cells as $cell) {
- $cell = tablesort_cell($cell, $header, $ts, $i++);
- $output .= _theme_table_cell($cell);
- }
- $output .= " </tr>\n";
- }
- }
- $output .= "</tbody>\n";
- }
- $output .= "</table>\n";
- return $output;
- }
- function theme_tablesort_indicator($variables) {
- if ($variables['style'] == "asc") {
- return theme('image', array('path' => 'misc/arrow-asc.png', 'width' => 13, 'height' => 13, 'alt' => t('sort ascending'), 'title' => t('sort ascending')));
- }
- else {
- return theme('image', array('path' => 'misc/arrow-desc.png', 'width' => 13, 'height' => 13, 'alt' => t('sort descending'), 'title' => t('sort descending')));
- }
- }
- function theme_mark($variables) {
- $type = $variables['type'];
- global $user;
- if ($user->uid) {
- if ($type == MARK_NEW) {
- return ' <span class="marker">' . t('new') . '</span>';
- }
- elseif ($type == MARK_UPDATED) {
- return ' <span class="marker">' . t('updated') . '</span>';
- }
- }
- }
- function theme_item_list($variables) {
- $items = $variables['items'];
- $title = $variables['title'];
- $type = $variables['type'];
- $attributes = $variables['attributes'];
-
-
-
- $output = '<div class="item-list">';
- if (isset($title) && $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) {
-
- $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>";
- }
- $output .= '</div>';
- return $output;
- }
- function theme_more_help_link($variables) {
- return '<div class="more-help-link">' . l(t('More help'), $variables['url']) . '</div>';
- }
- function theme_feed_icon($variables) {
- $text = t('Subscribe to !feed-title', array('!feed-title' => $variables['title']));
- if ($image = theme('image', array('path' => 'misc/feed.png', 'width' => 16, 'height' => 16, 'alt' => $text))) {
- return l($image, $variables['url'], array('html' => TRUE, 'attributes' => array('class' => array('feed-icon'), 'title' => $text)));
- }
- }
- function theme_html_tag($variables) {
- $element = $variables['element'];
- $attributes = isset($element['#attributes']) ? drupal_attributes($element['#attributes']) : '';
- if (!isset($element['#value'])) {
- return '<' . $element['#tag'] . $attributes . " />\n";
- }
- else {
- $output = '<' . $element['#tag'] . $attributes . '>';
- if (isset($element['#value_prefix'])) {
- $output .= $element['#value_prefix'];
- }
- $output .= $element['#value'];
- if (isset($element['#value_suffix'])) {
- $output .= $element['#value_suffix'];
- }
- $output .= '</' . $element['#tag'] . ">\n";
- return $output;
- }
- }
- function theme_more_link($variables) {
- return '<div class="more-link">' . l(t('More'), $variables['url'], array('attributes' => array('title' => $variables['title']))) . '</div>';
- }
- function theme_username($variables) {
- if (isset($variables['link_path'])) {
-
-
-
- $output = l($variables['name'] . $variables['extra'], $variables['link_path'], $variables['link_options']);
- }
- else {
-
-
-
- $output = '<span' . drupal_attributes($variables['attributes_array']) . '>' . $variables['name'] . $variables['extra'] . '</span>';
- }
- return $output;
- }
- function theme_progress_bar($variables) {
- $output = '<div id="progress" class="progress">';
- $output .= '<div class="bar"><div class="filled" style="width: ' . $variables['percent'] . '%"></div></div>';
- $output .= '<div class="percentage">' . $variables['percent'] . '%</div>';
- $output .= '<div class="message">' . $variables['message'] . '</div>';
- $output .= '</div>';
- return $output;
- }
- function theme_indentation($variables) {
- $output = '';
- for ($n = 0; $n < $variables['size']; $n++) {
- $output .= '<div class="indentation"> </div>';
- }
- return $output;
- }
- function _theme_table_cell($cell, $header = FALSE) {
- $attributes = '';
- if (is_array($cell)) {
- $data = isset($cell['data']) ? $cell['data'] : '';
-
- if (is_array($data)) {
- $data = drupal_render($data);
- }
- $header |= isset($cell['header']);
- unset($cell['data']);
- unset($cell['header']);
- $attributes = drupal_attributes($cell);
- }
- else {
- $data = $cell;
- }
- if ($header) {
- $output = "<th$attributes>$data</th>";
- }
- else {
- $output = "<td$attributes>$data</td>";
- }
- return $output;
- }
- function template_preprocess(&$variables, $hook) {
- global $user;
- static $count = array();
-
-
-
- $count[$hook] = isset($count[$hook]) && is_int($count[$hook]) ? $count[$hook] : 1;
- $variables['zebra'] = ($count[$hook] % 2) ? 'odd' : 'even';
- $variables['id'] = $count[$hook]++;
-
- $variables['directory'] = path_to_theme();
-
- $variables['classes_array'] = array(drupal_html_class($hook));
-
-
-
- static $drupal_static_fast;
- if (!isset($drupal_static_fast)) {
- $drupal_static_fast['default_variables'] = &drupal_static(__FUNCTION__);
- }
- $default_variables = &$drupal_static_fast['default_variables'];
-
-
-
- if (!isset($default_variables) || ($user !== $default_variables['user'])) {
- $default_variables = _template_preprocess_default_variables();
- }
- $variables += $default_variables;
- }
- function _template_preprocess_default_variables() {
- global $user;
-
- $variables = array(
- 'attributes_array' => array(),
- 'title_attributes_array' => array(),
- 'content_attributes_array' => array(),
- 'title_prefix' => array(),
- 'title_suffix' => array(),
- 'user' => $user,
- 'db_is_active' => !defined('MAINTENANCE_MODE'),
- 'is_admin' => FALSE,
- 'logged_in' => FALSE,
- );
-
-
-
- if (isset($user->uid) && function_exists('user_access')) {
- $variables['is_admin'] = user_access('access administration pages');
- $variables['logged_in'] = ($user->uid > 0);
- }
-
- try {
- $variables['is_front'] = drupal_is_front_page();
- }
- catch (Exception $e) {
-
-
- $variables['is_front'] = FALSE;
- $variables['db_is_active'] = FALSE;
- }
- return $variables;
- }
- function template_process(&$variables, $hook) {
-
- $variables['classes'] = implode(' ', $variables['classes_array']);
-
-
-
-
- $variables['attributes'] = $variables['attributes_array'] ? drupal_attributes($variables['attributes_array']) : '';
- $variables['title_attributes'] = $variables['title_attributes_array'] ? drupal_attributes($variables['title_attributes_array']) : '';
- $variables['content_attributes'] = $variables['content_attributes_array'] ? drupal_attributes($variables['content_attributes_array']) : '';
- }
- function template_preprocess_html(&$variables) {
-
-
-
- $variables['classes_array'][] = $variables['is_front'] ? 'front' : 'not-front';
-
- $variables['classes_array'][] = $variables['logged_in'] ? 'logged-in' : 'not-logged-in';
-
- if (!empty($variables['page']['sidebar_first']) && !empty($variables['page']['sidebar_second'])) {
- $variables['classes_array'][] = 'two-sidebars';
- }
- elseif (!empty($variables['page']['sidebar_first'])) {
- $variables['classes_array'][] = 'one-sidebar sidebar-first';
- }
- elseif (!empty($variables['page']['sidebar_second'])) {
- $variables['classes_array'][] = 'one-sidebar sidebar-second';
- }
- else {
- $variables['classes_array'][] = 'no-sidebars';
- }
-
- if ($suggestions = theme_get_suggestions(arg(), 'page', '-')) {
- foreach ($suggestions as $suggestion) {
- if ($suggestion != 'page-front') {
-
-
-
- $variables['classes_array'][] = drupal_html_class($suggestion);
- }
- }
- }
-
- if ($node = menu_get_object()) {
- $variables['classes_array'][] = drupal_html_class('node-type-' . $node->type);
- }
-
-
-
- $variables['rdf_namespaces'] = drupal_get_rdf_namespaces();
- $variables['grddl_profile'] = 'http://www.w3.org/1999/xhtml/vocab';
- $variables['language'] = $GLOBALS['language'];
- $variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
-
- if (theme_get_setting('toggle_favicon')) {
- $favicon = theme_get_setting('favicon');
- $type = theme_get_setting('favicon_mimetype');
- drupal_add_html_head_link(array('rel' => 'shortcut icon', 'href' => drupal_strip_dangerous_protocols($favicon), 'type' => $type));
- }
-
- if (drupal_get_title()) {
- $head_title = array(
- 'title' => strip_tags(drupal_get_title()),
- 'name' => check_plain(variable_get('site_name', 'Drupal')),
- );
- }
- else {
- $head_title = array('name' => check_plain(variable_get('site_name', 'Drupal')));
- if (variable_get('site_slogan', '')) {
- $head_title['slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
- }
- }
- $variables['head_title_array'] = $head_title;
- $variables['head_title'] = implode(' | ', $head_title);
-
- if ($suggestions = theme_get_suggestions(arg(), 'html')) {
- $variables['theme_hook_suggestions'] = $suggestions;
- }
- }
- function template_preprocess_page(&$variables) {
-
- $variables['show_messages'] = $variables['page']['#show_messages'];
- foreach (system_region_list($GLOBALS['theme'], REGIONS_ALL, FALSE) as $region_key) {
- if (!isset($variables['page'][$region_key])) {
- $variables['page'][$region_key] = array();
- }
- if ($region_content = drupal_get_region_content($region_key)) {
- $variables['page'][$region_key][]['#markup'] = $region_content;
- }
- }
-
- $variables['layout'] = 'none';
- if (!empty($variables['page']['sidebar_first'])) {
- $variables['layout'] = 'first';
- }
- if (!empty($variables['page']['sidebar_second'])) {
- $variables['layout'] = ($variables['layout'] == 'first') ? 'both' : 'second';
- }
- $variables['base_path'] = base_path();
- $variables['front_page'] = url();
- $variables['feed_icons'] = drupal_get_feeds();
- $variables['language'] = $GLOBALS['language'];
- $variables['language']->dir = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
- $variables['logo'] = theme_get_setting('logo');
- $variables['main_menu'] = theme_get_setting('toggle_main_menu') ? menu_main_menu() : array();
- $variables['secondary_menu'] = theme_get_setting('toggle_secondary_menu') ? menu_secondary_menu() : array();
- $variables['action_links'] = menu_local_actions();
- $variables['site_name'] = (theme_get_setting('toggle_name') ? filter_xss_admin(variable_get('site_name', 'Drupal')) : '');
- $variables['site_slogan'] = (theme_get_setting('toggle_slogan') ? filter_xss_admin(variable_get('site_slogan', '')) : '');
- $variables['tabs'] = menu_local_tabs();
- if ($node = menu_get_object()) {
- $variables['node'] = $node;
- }
-
- if ($suggestions = theme_get_suggestions(arg(), 'page')) {
- $variables['theme_hook_suggestions'] = $suggestions;
- }
- }
- function template_process_page(&$variables) {
- if (!isset($variables['breadcrumb'])) {
-
-
-
-
- $variables['breadcrumb'] = theme('breadcrumb', array('breadcrumb' => drupal_get_breadcrumb()));
- }
- if (!isset($variables['title'])) {
- $variables['title'] = drupal_get_title();
- }
-
-
- if (!isset($variables['messages'])) {
- $variables['messages'] = $variables['show_messages'] ? theme('status_messages') : '';
- }
- }
- function template_process_html(&$variables) {
-
- $variables['page_top'] = drupal_render($variables['page']['page_top']);
- $variables['page_bottom'] = drupal_render($variables['page']['page_bottom']);
-
- $variables['page'] = $variables['page']['#children'];
- $variables['page_bottom'] .= drupal_get_js('footer');
- $variables['head'] = drupal_get_html_head();
- $variables['css'] = drupal_add_css();
- $variables['styles'] = drupal_get_css();
- $variables['scripts'] = drupal_get_js();
- }
- function theme_get_suggestions($args, $base, $delimiter = '__') {
-
-
-
-
-
-
-
-
-
-
- $suggestions = array();
- $prefix = $base;
- foreach ($args as $arg) {
-
-
-
-
-
-
-
-
-
-
-
-
- $arg = str_replace(array("/", "\\", "\0", '-'), array('', '', '', '_'), $arg);
-
-
- if (is_numeric($arg)) {
- $suggestions[] = $prefix . $delimiter . '%';
- }
- $suggestions[] = $prefix . $delimiter . $arg;
- if (!is_numeric($arg)) {
- $prefix .= $delimiter . $arg;
- }
- }
- if (drupal_is_front_page()) {
-
- $suggestions[] = $base . $delimiter . 'front';
- }
- return $suggestions;
- }
- function template_preprocess_maintenance_page(&$variables) {
-
- if (theme_get_setting('toggle_favicon')) {
- $favicon = theme_get_setting('favicon');
- $type = theme_get_setting('favicon_mimetype');
- drupal_add_html_head_link(array('rel' => 'shortcut icon', 'href' => drupal_strip_dangerous_protocols($favicon), 'type' => $type));
- }
- global $theme;
-
- $theme_data = list_themes();
- $regions = $theme_data[$theme]->info['regions'];
-
- foreach (array_keys($regions) as $region) {
-
- $region_content = drupal_get_region_content($region);
- isset($variables[$region]) ? $variables[$region] .= $region_content : $variables[$region] = $region_content;
- }
-
- $variables['layout'] = 'none';
- if (!empty($variables['sidebar_first'])) {
- $variables['layout'] = 'first';
- }
- if (!empty($variables['sidebar_second'])) {
- $variables['layout'] = ($variables['layout'] == 'first') ? 'both' : 'second';
- }
-
- if (drupal_get_title()) {
- $head_title = array(
- 'title' => strip_tags(drupal_get_title()),
- 'name' => variable_get('site_name', 'Drupal'),
- );
- }
- else {
- $head_title = array('name' => variable_get('site_name', 'Drupal'));
- if (variable_get('site_slogan', '')) {
- $head_title['slogan'] = variable_get('site_slogan', '');
- }
- }
-
- $language = isset($GLOBALS['language']) ? $GLOBALS['language'] : language_default();
- $variables['head_title_array'] = $head_title;
- $variables['head_title'] = implode(' | ', $head_title);
- $variables['base_path'] = base_path();
- $variables['front_page'] = url();
- $variables['breadcrumb'] = '';
- $variables['feed_icons'] = '';
- $variables['help'] = '';
- $variables['language'] = $language;
- $variables['language']->dir = $language->direction ? 'rtl' : 'ltr';
- $variables['logo'] = theme_get_setting('logo');
- $variables['messages'] = $variables['show_messages'] ? theme('status_messages') : '';
- $variables['main_menu'] = array();
- $variables['secondary_menu'] = array();
- $variables['site_name'] = (theme_get_setting('toggle_name') ? variable_get('site_name', 'Drupal') : '');
- $variables['site_slogan'] = (theme_get_setting('toggle_slogan') ? variable_get('site_slogan', '') : '');
- $variables['tabs'] = '';
- $variables['title'] = drupal_get_title();
-
- $variables['classes_array'][] = 'in-maintenance';
- if (isset($variables['db_is_active']) && !$variables['db_is_active']) {
- $variables['classes_array'][] = 'db-offline';
- }
- if ($variables['layout'] == 'both') {
- $variables['classes_array'][] = 'two-sidebars';
- }
- elseif ($variables['layout'] == 'none') {
- $variables['classes_array'][] = 'no-sidebars';
- }
- else {
- $variables['classes_array'][] = 'one-sidebar sidebar-' . $variables['layout'];
- }
-
-
- if (isset($variables['db_is_active']) && !$variables['db_is_active']) {
- $variables['theme_hook_suggestion'] = 'maintenance_page__offline';
- }
- }
- function template_process_maintenance_page(&$variables) {
- $variables['head'] = drupal_get_html_head();
- $variables['css'] = drupal_add_css();
- $variables['styles'] = drupal_get_css();
- $variables['scripts'] = drupal_get_js();
- }
- function template_preprocess_region(&$variables) {
-
- $variables['content'] = $variables['elements']['#children'];
- $variables['region'] = $variables['elements']['#region'];
- $variables['classes_array'][] = drupal_region_class($variables['region']);
- $variables['theme_hook_suggestions'][] = 'region__' . $variables['region'];
- }
- function template_preprocess_username(&$variables) {
- $account = $variables['account'];
- $variables['extra'] = '';
- if (empty($account->uid)) {
- $variables['uid'] = 0;
- if (theme_get_setting('toggle_comment_user_verification')) {
- $variables['extra'] = ' (' . t('not verified') . ')';
- }
- }
- else {
- $variables['uid'] = (int) $account->uid;
- }
-
-
-
-
-
- $name = $variables['name_raw'] = format_username($account);
- if (drupal_strlen($name) > 20) {
- $name = drupal_substr($name, 0, 15) . '...';
- }
- $variables['name'] = check_plain($name);
- $variables['profile_access'] = user_access('access user profiles');
- $variables['link_attributes'] = array();
-
- if ($variables['uid'] && $variables['profile_access']) {
-
- $variables['link_attributes'] = array('title' => t('View user profile.'));
- $variables['link_path'] = 'user/' . $variables['uid'];
- }
- elseif (!empty($account->homepage)) {
-
-
-
- $variables['link_attributes'] = array('rel' => array('nofollow'));
- $variables['link_path'] = $account->homepage;
- $variables['homepage'] = $account->homepage;
- }
-
- $variables['link_options']['html'] = TRUE;
-
- $variables['attributes_array'] = array('class' => array('username'));
- }
- function template_process_username(&$variables) {
-
-
-
- if (isset($variables['link_path'])) {
-
-
-
-
-
-
-
- $variables['link_options']['attributes'] = array_merge_recursive($variables['link_attributes'], $variables['attributes_array']);
- }
- }
|