template.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. <?php
  2. /*
  3. * Implements hook_preprocess_html().
  4. */
  5. function rubik_preprocess_html(&$vars) {
  6. if (theme_get_setting('rubik_inline_field_descriptions')) {
  7. $vars['classes_array'][] = 'rubik-inline-field-descriptions';
  8. }
  9. // add in a specific stylesheet for overrides in IE7. (BLAH)
  10. drupal_add_css(drupal_get_path('theme', 'rubik') . '/css/ie.css', array(
  11. 'browsers' => array(
  12. '!IE' => FALSE,
  13. ),
  14. 'weight' => 500,
  15. 'group' => 5000,
  16. 'every_page' => TRUE,
  17. ));
  18. // Disable sticky in the sidebar. Set option in JS
  19. $disable_sticky = theme_get_setting('rubik_disable_sticky_sidebar');
  20. drupal_add_js(array('rubik' => array('disable_sticky' => $disable_sticky)), array('type' => 'setting'));
  21. }
  22. /**
  23. * Implements hook_css_alter().
  24. * @TODO: Do this in .info once http://drupal.org/node/575298 is committed.
  25. */
  26. function rubik_css_alter(&$css) {
  27. if (isset($css['modules/overlay/overlay-child.css'])) {
  28. $css['modules/overlay/overlay-child.css']['data'] = drupal_get_path('theme', 'rubik') . '/css/overlay-child.css';
  29. }
  30. if (isset($css['modules/shortcut/shortcut.css'])) {
  31. $css['modules/shortcut/shortcut.css']['data'] = drupal_get_path('theme', 'rubik') . '/css/shortcut.css';
  32. }
  33. }
  34. /**
  35. * Implementation of hook_theme().
  36. */
  37. function rubik_theme() {
  38. $items = array();
  39. // Content theming.
  40. $items['help'] =
  41. $items['node'] =
  42. $items['comment'] =
  43. $items['comment_wrapper'] = array(
  44. 'path' => drupal_get_path('theme', 'rubik') .'/templates',
  45. 'template' => 'object',
  46. );
  47. $items['node']['template'] = 'node';
  48. // Help pages really need help. See preprocess_page().
  49. $items['help_page'] = array(
  50. 'variables' => array('content' => array()),
  51. 'path' => drupal_get_path('theme', 'rubik') .'/templates',
  52. 'template' => 'object',
  53. 'preprocess functions' => array(
  54. 'template_preprocess',
  55. 'rubik_preprocess_help_page',
  56. ),
  57. 'process functions' => array('template_process'),
  58. );
  59. if (!theme_get_setting('rubik_disable_sidebar_in_form')) {
  60. // Form layout: default (2 column).
  61. $items['block_add_block_form'] =
  62. $items['block_admin_configure'] =
  63. $items['comment_form'] =
  64. $items['contact_admin_edit'] =
  65. $items['contact_mail_page'] =
  66. $items['contact_mail_user'] =
  67. $items['filter_admin_format_form'] =
  68. $items['forum_form'] =
  69. $items['locale_languages_edit_form'] =
  70. $items['menu_edit_menu'] =
  71. $items['menu_edit_item'] =
  72. $items['node_type_form'] =
  73. $items['path_admin_form'] =
  74. $items['system_settings_form'] =
  75. $items['system_themes_form'] =
  76. $items['system_modules'] =
  77. $items['system_actions_configure'] =
  78. $items['taxonomy_form_term'] =
  79. $items['taxonomy_form_vocabulary'] =
  80. $items['user_profile_form'] =
  81. $items['user_admin_access_add_form'] = array(
  82. 'render element' => 'form',
  83. 'path' => drupal_get_path('theme', 'rubik') .'/templates',
  84. 'template' => 'form-default',
  85. 'preprocess functions' => array(
  86. 'rubik_preprocess_form_buttons',
  87. ),
  88. );
  89. // These forms require additional massaging.
  90. $items['confirm_form'] = array(
  91. 'render element' => 'form',
  92. 'path' => drupal_get_path('theme', 'rubik') .'/templates',
  93. 'template' => 'form-simple',
  94. 'preprocess functions' => array(
  95. 'rubik_preprocess_form_confirm'
  96. ),
  97. );
  98. $items['node_form'] = array(
  99. 'render element' => 'form',
  100. 'path' => drupal_get_path('theme', 'rubik') .'/templates',
  101. 'template' => 'form-default',
  102. 'preprocess functions' => array(
  103. 'rubik_preprocess_form_buttons',
  104. 'rubik_preprocess_form_node',
  105. ),
  106. );
  107. }
  108. return $items;
  109. }
  110. /**
  111. * Preprocessor for theme('page').
  112. */
  113. function rubik_preprocess_page(&$vars) {
  114. // Show a warning if base theme is not present.
  115. if (!function_exists('tao_theme') && user_access('administer site configuration')) {
  116. drupal_set_message(t('The Rubik theme requires the !tao base theme in order to work properly.', array('!tao' => l('Tao', 'http://drupal.org/project/tao'))), 'warning');
  117. }
  118. // Set a page icon class.
  119. $vars['page_icon_class'] = ($item = menu_get_item()) ? implode(' ' , _rubik_icon_classes($item['href'])) : '';
  120. // Help pages. They really do need help.
  121. if (strpos($_GET['q'], 'admin/help/') === 0 && isset($vars['page']['content']['system_main']['main']['#markup'])) {
  122. $vars['page']['content']['system_main']['main']['#markup'] = theme('help_page', array('content' => $vars['page']['content']['system_main']['main']['#markup']));
  123. }
  124. // Clear out help text if empty.
  125. if (empty($vars['help']) || !(strip_tags($vars['help']))) {
  126. $vars['help'] = '';
  127. }
  128. // Process local tasks. This will get called for rubik and its subthemes.
  129. _rubik_local_tasks($vars);
  130. // Overlay is enabled.
  131. $vars['overlay'] = (module_exists('overlay') && overlay_get_mode() === 'child');
  132. }
  133. /**
  134. * Preprocessor for theme('fieldset').
  135. */
  136. function rubik_preprocess_fieldset(&$vars) {
  137. if (!empty($vars['element']['#collapsible'])) {
  138. $vars['title'] = "<span class='icon'></span>" . $vars['title'];
  139. }
  140. }
  141. /**
  142. * Preprocessor for handling form button for most forms.
  143. */
  144. function rubik_preprocess_form_buttons(&$vars) {
  145. if (!empty($vars['form']['actions'])) {
  146. $vars['actions'] = $vars['form']['actions'];
  147. unset($vars['form']['actions']);
  148. }
  149. }
  150. /**
  151. * Preprocessor for theme('confirm_form').
  152. */
  153. function rubik_preprocess_form_confirm(&$vars) {
  154. // Move the title from the page title (usually too big and unwieldy)
  155. $title = filter_xss_admin(drupal_get_title());
  156. $vars['form']['description']['#type'] = 'item';
  157. $vars['form']['description']['#value'] = empty($vars['form']['description']['#value']) ?
  158. "<strong>{$title}</strong>" :
  159. "<strong>{$title}</strong><p>{$vars['form']['description']['#value']}</p>";
  160. drupal_set_title(t('Please confirm'));
  161. }
  162. /**
  163. * Preprocessor for theme('node_form').
  164. */
  165. function rubik_preprocess_form_node(&$vars) {
  166. $vars['sidebar'] = isset($vars['sidebar']) ? $vars['sidebar'] : array();
  167. $map = array();
  168. // Support field_group if present.
  169. if (module_exists('field_group')) {
  170. $map += array(
  171. 'group_sidebar' => 'sidebar',
  172. 'group_footer' => 'footer',
  173. );
  174. }
  175. // Support nodeformcols if present.
  176. if (module_exists('nodeformcols')) {
  177. $map += array(
  178. 'nodeformcols_region_right' => 'sidebar',
  179. 'nodeformcols_region_footer' => 'footer',
  180. 'nodeformcols_region_main' => NULL,
  181. );
  182. }
  183. if (isset($map)) {
  184. foreach ($map as $region => $target) {
  185. if (isset($vars['form'][$region])) {
  186. if (isset($vars['form'][$region]['#prefix'], $vars['form'][$region]['#suffix'])) {
  187. unset($vars['form'][$region]['#prefix']);
  188. unset($vars['form'][$region]['#suffix']);
  189. }
  190. if (isset($vars['form'][$region]['actions'], $vars['form'][$region]['actions'])) {
  191. $vars['actions'] = $vars['form'][$region]['actions'];
  192. unset($vars['form'][$region]['actions']);
  193. }
  194. if (isset($target)) {
  195. $vars[$target] = $vars['form'][$region];
  196. unset($vars['form'][$region]);
  197. }
  198. }
  199. }
  200. }
  201. // Default to showing taxonomy in sidebar if nodeformcols is not present.
  202. elseif (isset($vars['form']['taxonomy']) && empty($vars['sidebar'])) {
  203. $vars['sidebar']['taxonomy'] = $vars['form']['taxonomy'];
  204. unset($vars['form']['taxonomy']);
  205. }
  206. }
  207. /**
  208. * Preprocessor for theme('button').
  209. */
  210. function rubik_preprocess_button(&$vars) {
  211. if (isset($vars['element']['#value'])) {
  212. $classes = array(
  213. t('Save') => 'yes',
  214. t('Submit') => 'yes',
  215. t('Yes') => 'yes',
  216. t('Add') => 'add',
  217. t('Delete') => 'remove',
  218. t('Remove') => 'remove',
  219. t('Cancel') => 'no',
  220. t('No') => 'no',
  221. );
  222. foreach ($classes as $search => $class) {
  223. if (strpos($vars['element']['#value'], $search) !== FALSE) {
  224. $vars['element']['#attributes']['class'][] = 'button-' . $class;
  225. break;
  226. }
  227. }
  228. }
  229. }
  230. /**
  231. * Preprocessor for theme('help').
  232. */
  233. function rubik_preprocess_help(&$vars) {
  234. $vars['hook'] = 'help';
  235. $vars['attr']['id'] = 'help-text';
  236. $class = 'path-admin-help clear-block toggleable';
  237. $vars['attr']['class'] = isset($vars['attr']['class']) ? "{$vars['attr']['class']} $class" : $class;
  238. $help = menu_get_active_help();
  239. if (($test = strip_tags($help)) && !empty($help)) {
  240. // Thankfully this is static cached.
  241. $vars['attr']['class'] .= menu_secondary_local_tasks() ? ' with-tabs' : '';
  242. $vars['is_prose'] = TRUE;
  243. $vars['layout'] = TRUE;
  244. $vars['content'] = "<span class='icon'></span>" . $help;
  245. // Link to help section.
  246. $item = menu_get_item('admin/help');
  247. if ($item && $item['path'] === 'admin/help' && $item['access']) {
  248. $vars['links'] = l(t('More help topics'), 'admin/help');
  249. }
  250. }
  251. }
  252. /**
  253. * Preprocessor for theme('help_page').
  254. */
  255. function rubik_preprocess_help_page(&$vars) {
  256. $vars['hook'] = 'help-page';
  257. $vars['title_attributes_array']['class'][] = 'help-page-title';
  258. $vars['title_attributes_array']['class'][] = 'clearfix';
  259. $vars['content_attributes_array']['class'][] = 'help-page-content';
  260. $vars['content_attributes_array']['class'][] = 'clearfix';
  261. $vars['content_attributes_array']['class'][] = 'prose';
  262. $vars['layout'] = TRUE;
  263. // Truly hackish way to navigate help pages.
  264. $module_info = system_rebuild_module_data();
  265. $empty_arg = drupal_help_arg();
  266. $modules = array();
  267. foreach (module_implements('help', TRUE) as $module) {
  268. if (module_invoke($module, 'help', "admin/help#$module", $empty_arg)) {
  269. $modules[$module] = $module_info[$module]->info['name'];
  270. }
  271. }
  272. asort($modules);
  273. $links = array();
  274. foreach ($modules as $module => $name) {
  275. $links[] = array('title' => $name, 'href' => "admin/help/{$module}");
  276. }
  277. $vars['links'] = theme('links', array('links' => $links));
  278. }
  279. /**
  280. * Preprocessor for theme('node').
  281. */
  282. function rubik_preprocess_node(&$vars) {
  283. $vars['layout'] = TRUE;
  284. if ($vars['display_submitted']) {
  285. $vars['submitted'] = _rubik_submitted($vars['node']);
  286. }
  287. }
  288. /**
  289. * Preprocessor for theme('comment').
  290. */
  291. function rubik_preprocess_comment(&$vars) {
  292. $vars['layout'] = TRUE;
  293. $vars['submitted'] = _rubik_submitted($vars['comment']);
  294. }
  295. /**
  296. * Preprocessor for theme('comment_wrapper').
  297. */
  298. function rubik_preprocess_comment_wrapper(&$vars) {
  299. $vars['hook'] = 'box';
  300. $vars['layout'] = FALSE;
  301. $vars['title'] = t('Comments');
  302. $vars['attributes_array']['id'] = 'comments';
  303. $vars['title_attributes_array']['class'][] = 'box-title';
  304. $vars['title_attributes_array']['class'][] = 'clearfix';
  305. $vars['content_attributes_array']['class'][] = 'box-content';
  306. $vars['content_attributes_array']['class'][] = 'clearfix';
  307. $vars['content_attributes_array']['class'][] = 'prose';
  308. $vars['content'] = drupal_render_children($vars['content']);
  309. }
  310. /**
  311. * Preprocessor for theme('admin_block').
  312. */
  313. function rubik_preprocess_admin_block(&$vars) {
  314. // Add icon and classes to admin block titles.
  315. if (isset($vars['block']['href'])) {
  316. $vars['block']['localized_options']['attributes']['class'] = _rubik_icon_classes($vars['block']['href']);
  317. }
  318. $vars['block']['localized_options']['html'] = TRUE;
  319. if (isset($vars['block']['link_title'])) {
  320. $vars['block']['title'] = l("<span class='icon'></span>" . filter_xss_admin($vars['block']['title']), $vars['block']['href'], $vars['block']['localized_options']);
  321. }
  322. if (empty($vars['block']['content'])) {
  323. $vars['block']['content'] = "<div class='admin-block-description description'>{$vars['block']['description']}</div>";
  324. }
  325. }
  326. /**
  327. * Override of theme('breadcrumb').
  328. */
  329. function rubik_breadcrumb($vars) {
  330. $output = '';
  331. // Add current page onto the end.
  332. if (!drupal_is_front_page()) {
  333. $item = menu_get_item();
  334. $end = end($vars['breadcrumb']);
  335. if ($end && strip_tags($end) !== $item['title']) {
  336. $vars['breadcrumb'][] = (isset($item['localized_options']['html']) && $item['localized_options']['html']) ? $item['title'] : check_plain($item['title']);
  337. }
  338. }
  339. // Optional: Add the site name to the front of the stack.
  340. if (!empty($vars['prepend'])) {
  341. $site_name = empty($vars['breadcrumb']) ? "<strong>". check_plain(variable_get('site_name', '')) ."</strong>" : l(variable_get('site_name', ''), '<front>', array('purl' => array('disabled' => TRUE)));
  342. array_unshift($vars['breadcrumb'], $site_name);
  343. }
  344. $depth = 0;
  345. foreach ($vars['breadcrumb'] as $link) {
  346. // If the item isn't a link, surround it with a strong tag to format it like
  347. // one.
  348. if (!preg_match('/^<a/', $link) && !preg_match('/^<strong/', $link)) {
  349. $link = '<strong>' . $link . '</strong>';
  350. }
  351. $output .= "<span class='breadcrumb-link breadcrumb-depth-{$depth}'>{$link}</span>";
  352. $depth++;
  353. }
  354. return $output;
  355. }
  356. /**
  357. * Override of theme('filter_guidelines').
  358. */
  359. function rubik_filter_guidelines($variables) {
  360. return '';
  361. }
  362. /**
  363. * Override of theme('node_add_list').
  364. */
  365. function rubik_node_add_list($vars) {
  366. $content = $vars['content'];
  367. $output = "<ul class='admin-list'>";
  368. if ($content) {
  369. foreach ($content as $item) {
  370. $item['title'] = "<span class='icon'></span>" . filter_xss_admin($item['title']);
  371. if (isset($item['localized_options']['attributes']['class'])) {
  372. $item['localized_options']['attributes']['class'] += _rubik_icon_classes($item['href']);
  373. }
  374. else {
  375. $item['localized_options']['attributes']['class'] = _rubik_icon_classes($item['href']);
  376. }
  377. $item['localized_options']['html'] = TRUE;
  378. $output .= "<li>";
  379. $output .= l($item['title'], $item['href'], $item['localized_options']);
  380. $output .= '<div class="description">'. filter_xss_admin($item['description']) .'</div>';
  381. $output .= "</li>";
  382. }
  383. }
  384. $output .= "</ul>";
  385. return $output;
  386. }
  387. /**
  388. * Override of theme_admin_block_content().
  389. */
  390. function rubik_admin_block_content($vars) {
  391. $content = $vars['content'];
  392. $output = '';
  393. if (!empty($content)) {
  394. foreach ($content as $k => $item) {
  395. //-- Safety check for invalid clients of the function
  396. if (empty($content[$k]['localized_options']['attributes']['class'])) {
  397. $content[$k]['localized_options']['attributes']['class'] = array();
  398. }
  399. if (!is_array($content[$k]['localized_options']['attributes']['class'])) {
  400. $content[$k]['localized_options']['attributes']['class'] = array($content[$k]['localized_options']['attributes']['class']);
  401. }
  402. $content[$k]['title'] = "<span class='icon'></span>" . filter_xss_admin($item['title']);
  403. $content[$k]['localized_options']['html'] = TRUE;
  404. if (!empty($content[$k]['localized_options']['attributes']['class'])) {
  405. $content[$k]['localized_options']['attributes']['class'] += _rubik_icon_classes($item['href']);
  406. }
  407. else {
  408. $content[$k]['localized_options']['attributes']['class'] = _rubik_icon_classes($item['href']);
  409. }
  410. }
  411. $output = system_admin_compact_mode() ? '<ul class="admin-list admin-list-compact">' : '<ul class="admin-list">';
  412. foreach ($content as $item) {
  413. $output .= '<li class="leaf">';
  414. $output .= l($item['title'], $item['href'], $item['localized_options']);
  415. if (isset($item['description']) && !system_admin_compact_mode()) {
  416. $output .= "<div class='description'>{$item['description']}</div>";
  417. }
  418. $output .= '</li>';
  419. }
  420. $output .= '</ul>';
  421. }
  422. return $output;
  423. }
  424. /**
  425. * Override of theme('admin_drilldown_menu_item_link').
  426. */
  427. function rubik_admin_drilldown_menu_item_link($link) {
  428. $link['localized_options'] = empty($link['localized_options']) ? array() : $link['localized_options'];
  429. $link['localized_options']['html'] = TRUE;
  430. if (!isset($link['localized_options']['attributes']['class'])) {
  431. $link['localized_options']['attributes']['class'] = _rubik_icon_classes($link['href']);
  432. }
  433. else {
  434. $link['localized_options']['attributes']['class'] += _rubik_icon_classes($link['href']);
  435. }
  436. $link['description'] = check_plain(truncate_utf8(strip_tags($link['description']), 150, TRUE, TRUE));
  437. $link['description'] = "<span class='icon'></span>" . $link['description'];
  438. $link['title'] .= !empty($link['description']) ? "<span class='menu-description'>{$link['description']}</span>" : '';
  439. $link['title'] = filter_xss_admin($link['title']);
  440. return l($link['title'], $link['href'], $link['localized_options']);
  441. }
  442. /**
  443. * Preprocessor for theme('textfield').
  444. */
  445. function rubik_preprocess_textfield(&$vars) {
  446. if ($vars['element']['#size'] >= 30 && empty($vars['element']['#field_prefix']) && empty($vars['element']['#field_suffix'])) {
  447. // Set text field to default size.
  448. $vars['element']['#size'] = 20;
  449. if (!isset($vars['element']['#attributes']['class'])
  450. || !is_array($vars['element']['#attributes']['class'])) {
  451. $vars['element']['#attributes']['class'] = array();
  452. }
  453. $vars['element']['#attributes']['class'][] = 'fluid';
  454. }
  455. }
  456. /**
  457. * Override of theme('menu_local_task').
  458. */
  459. function rubik_menu_local_task($variables) {
  460. $link = $variables['element']['#link'];
  461. $link_text = $link['title'];
  462. if (!empty($variables['element']['#active'])) {
  463. // Add text to indicate active tab for non-visual users.
  464. $active = '<span class="element-invisible">' . t('(active tab)') . '</span>';
  465. // If the link does not contain HTML already, check_plain() it now.
  466. // After we set 'html'=TRUE the link will not be sanitized by l().
  467. if (empty($link['localized_options']['html'])) {
  468. $link['title'] = check_plain($link['title']);
  469. }
  470. $link['localized_options']['html'] = TRUE;
  471. $link_text = t('!local-task-title!active', array('!local-task-title' => $link['title'], '!active' => $active));
  472. }
  473. // Render child tasks if available.
  474. $children = '';
  475. if (element_children($variables['element'])) {
  476. $children = drupal_render_children($variables['element']);
  477. $children = "<ul class='secondary-tabs links clearfix'>{$children}</ul>";
  478. }
  479. return '<li' . (!empty($variables['element']['#active']) ? ' class="active"' : '') . '>' . l($link_text, $link['href'], $link['localized_options']) . $children . "</li>\n";
  480. }
  481. /**
  482. * Helper function for cloning and drupal_render()'ing elements.
  483. */
  484. function rubik_render_clone($elements) {
  485. static $instance;
  486. if (!isset($instance)) {
  487. $instance = 1;
  488. }
  489. foreach (element_children($elements) as $key) {
  490. if (isset($elements[$key]['#id'])) {
  491. $elements[$key]['#id'] = "{$elements[$key]['#id']}-{$instance}";
  492. }
  493. }
  494. $instance++;
  495. return drupal_render($elements);
  496. }
  497. function rubik_form_field_ui_field_edit_form_alter(&$form, &$form_state) {
  498. $rubik_sidebar_field_ui = theme_get_setting('rubik_sidebar_field_ui', 'rubik');
  499. $rubik_disable_sidebar_in_form = theme_get_setting('rubik_disable_sidebar_in_form', 'rubik');
  500. if ($rubik_sidebar_field_ui == 1 && $rubik_disable_sidebar_in_form == 0) {
  501. $options = array(
  502. 'default' => t('Default'),
  503. 'rubik_sidebar_field' => t('Sidebar'),
  504. );
  505. $default = (isset($form_state['build_info']['args'][0]['rubik_edit_field_display'])) ? $form_state['build_info']['args'][0]['rubik_edit_field_display'] : 'default';
  506. $form['instance']['rubik_edit_field_display'] = array(
  507. '#type' => 'radios',
  508. '#title' => t('Set field display location'),
  509. '#description' => t('Choose where this field should be displayed.'),
  510. '#default_value' => $default,
  511. '#options' => $options,
  512. );
  513. }
  514. }
  515. function rubik_form_node_form_alter(&$form, $form_state) {
  516. $rubik_sidebar_field_ui = theme_get_setting('rubik_sidebar_field_ui', 'rubik');
  517. if ($rubik_sidebar_field_ui == TRUE) {
  518. if (isset($form_state['field']) && is_array($form_state['field'])) {
  519. foreach ($form_state['field'] AS $name => $field) {
  520. if (!isset($field[LANGUAGE_NONE]['instance'])) {
  521. continue;
  522. }
  523. if (isset($field[LANGUAGE_NONE]['instance']['rubik_edit_field_display'])) {
  524. $display = $field[LANGUAGE_NONE]['instance']['rubik_edit_field_display'];
  525. if ($display == 'rubik_sidebar_field') {
  526. $form[$name]['#attributes']['class'][] = 'rubik_sidebar_field';
  527. }
  528. }
  529. }
  530. }
  531. }
  532. }
  533. /**
  534. * Helper function to submitted info theming functions.
  535. */
  536. function _rubik_submitted($node) {
  537. $byline = t('Posted by !username', array('!username' => theme('username', array('account' => $node))));
  538. $date = format_date($node->created, 'small');
  539. return "<div class='byline'>{$byline}</div><div class='date'>$date</div>";
  540. }
  541. /**
  542. * Generate an icon class from a path.
  543. */
  544. function _rubik_icon_classes($path) {
  545. $classes = array();
  546. $args = explode('/', $path);
  547. if ($args[0] === 'admin' || (count($args) > 1 && $args[0] === 'node' && $args[1] === 'add')) {
  548. // Add a class specifically for the current path that allows non-cascading
  549. // style targeting.
  550. $classes[] = 'path-'. str_replace('/', '-', implode('/', $args)) . '-';
  551. while (count($args)) {
  552. $classes[] = drupal_html_class('path-'. str_replace('/', '-', implode('/', $args)));
  553. array_pop($args);
  554. }
  555. return $classes;
  556. }
  557. return array();
  558. }
  559. function _rubik_local_tasks(&$vars) {
  560. if (!empty($vars['secondary_local_tasks']) && is_array($vars['primary_local_tasks'])) {
  561. foreach ($vars['primary_local_tasks'] as $key => $element) {
  562. if (!empty($element['#active'])) {
  563. $vars['primary_local_tasks'][$key] = $vars['primary_local_tasks'][$key] + $vars['secondary_local_tasks'];
  564. break;
  565. }
  566. }
  567. }
  568. }