12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993 |
- <?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();
- 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 . '/', $functions['user']);
- 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 = $variables['links'];
- $attributes = $variables['attributes'];
- $heading = $variables['heading'];
- global $language_url;
- $output = '';
- if (count($links) > 0) {
-
-
- 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 (count($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 (count($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 (!count($rows) && $empty) {
- $header_count = 0;
- 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 (count($header)) {
- $ts = tablesort_init($header);
-
-
- $output .= (count($rows) ? ' <thead><tr>' : ' <tr>');
- foreach ($header as $cell) {
- $cell = tablesort_header($cell, $header, $ts);
- $output .= _theme_table_cell($cell, TRUE);
- }
-
- $output .= (count($rows) ? " </tr></thead>\n" : "</tr>\n");
- }
- else {
- $ts = array();
- }
-
- if (count($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 (count($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']) as $region_key => $region_name) {
- 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']);
- }
- }
|