PageRenderTime 45ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/sites/all/themes/contrib/ember/template.php

https://gitlab.com/inzorcom/sofline-test
PHP | 311 lines | 191 code | 37 blank | 83 comment | 35 complexity | b44c4582f26aa0a1e2c2fc42ab8c6973 MD5 | raw file
  1. <?php
  2. /**
  3. * Implements hook_html_head_alter().
  4. */
  5. function ember_html_head_alter(&$head_elements) {
  6. $head_elements['viewport'] = array(
  7. '#type' => 'html_tag',
  8. '#tag' => 'meta',
  9. '#attributes' => array(
  10. 'name' => 'viewport',
  11. 'content' => 'width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0'),
  12. );
  13. }
  14. /*add a ember class to the header to give targetability for css enhancements */
  15. function ember_preprocess_html(&$variables) {
  16. $variables['classes_array'][] = 'ember';
  17. }
  18. /**
  19. * Override or insert variables into the page template.
  20. */
  21. function ember_process_page(&$vars) {
  22. if (theme_get_setting('display_breadcrumbs') == 1) {
  23. unset($vars['breadcrumb']);
  24. }
  25. }
  26. /**
  27. * Display the list of available node types for node creation.
  28. */
  29. function ember_node_add_list($variables) {
  30. $content = $variables['content'];
  31. $output = '';
  32. if ($content) {
  33. $output = '<ul class="admin-list">';
  34. foreach ($content as $item) {
  35. $output .= '<li class="clearfix">';
  36. $output .= '<span class="label">' . l($item['title'], $item['href'], $item['localized_options']) . '</span>';
  37. $output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>';
  38. $output .= '</li>';
  39. }
  40. $output .= '</ul>';
  41. }
  42. else {
  43. $output = '<p>' . t('You have not created any content types yet. Go to the <a href="@create-content">content type creation page</a> to add a new content type.', array('@create-content' => url('admin/structure/types/add'))) . '</p>';
  44. }
  45. return $output;
  46. }
  47. /**
  48. * Overrides theme_admin_block_content().
  49. *
  50. * Use unordered list markup in both compact and extended mode.
  51. */
  52. function ember_admin_block_content($variables) {
  53. $content = $variables['content'];
  54. $output = '';
  55. if (!empty($content)) {
  56. $output = system_admin_compact_mode() ? '<ul class="admin-list compact">' : '<ul class="admin-list">';
  57. foreach ($content as $item) {
  58. $output .= '<li class="leaf">';
  59. $output .= l($item['title'], $item['href'], $item['localized_options']);
  60. if (isset($item['description']) && !system_admin_compact_mode()) {
  61. $output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>';
  62. }
  63. $output .= '</li>';
  64. }
  65. $output .= '</ul>';
  66. }
  67. return $output;
  68. }
  69. /**
  70. * Override of theme_tablesort_indicator().
  71. *
  72. * Use our own image versions, so they show up as black and not gray on gray.
  73. */
  74. function ember_tablesort_indicator($variables) {
  75. $style = $variables['style'];
  76. $theme_path = drupal_get_path('theme', 'ember');
  77. if ($style == 'asc') {
  78. return theme('image', array('path' => $theme_path . '/images/arrow-asc.png', 'alt' => t('sort ascending'), 'width' => 13, 'height' => 13, 'title' => t('sort ascending')));
  79. }
  80. else {
  81. return theme('image', array('path' => $theme_path . '/images/arrow-desc.png', 'alt' => t('sort descending'), 'width' => 13, 'height' => 13, 'title' => t('sort descending')));
  82. }
  83. }
  84. /**
  85. * Implements hook_css_alter().
  86. */
  87. function ember_css_alter(&$css) {
  88. // Use Ember's jQuery UI styles instead of the defaults.
  89. $jquery = array('core', 'dialog', 'tabs', 'theme');
  90. foreach($jquery as $module) {
  91. if (isset($css['misc/ui/jquery.ui.' . $module . '.css'])) {
  92. $css['misc/ui/jquery.ui.' . $module . '.css']['data'] = drupal_get_path('theme', 'ember') . '/styles/jquery.ui.' . $module . '.css';
  93. }
  94. }
  95. // If the media module is installed, Replace it with Ember's.
  96. if (module_exists('media')) {
  97. $media_path = drupal_get_path('module', 'media') . '/css/media.css';
  98. if(isset($css[$media_path])) {
  99. $css[$media_path]['data'] = drupal_get_path('theme', 'ember') . '/styles/media.css';
  100. }
  101. }
  102. // If the responsive vertical tabs module is installed, add ember themeing overrides to it
  103. if (module_exists('responsive_vertical_tabs')) {
  104. $rvt_theme_path = drupal_get_path('module', 'responsive_vertical_tabs') . '/css/vertical-tabs-theme.css';
  105. if(isset($css[$rvt_theme_path])) {
  106. $css[$rvt_theme_path]['data'] = drupal_get_path('theme', 'ember') . '/styles/vertical-tabs-theme.css';
  107. }
  108. }
  109. }
  110. /**
  111. * Overrides theme_links__ctools_dropbutton().
  112. *
  113. * This override adds a wrapper div so that we can maintain appropriate
  114. * vertical spacing.
  115. */
  116. function ember_links__ctools_dropbutton($variables) {
  117. // Check to see if the number of links is greater than 1;
  118. // otherwise just treat this like a button.
  119. if (!empty($variables['links'])) {
  120. $is_drop_button = (count($variables['links']) > 1);
  121. // Add needed files
  122. if ($is_drop_button) {
  123. ctools_add_js('dropbutton');
  124. ctools_add_css('dropbutton');
  125. }
  126. ctools_add_css('button');
  127. // Provide a unique identifier for every button on the page.
  128. static $id = 0;
  129. $id++;
  130. // Wrapping div
  131. $class = 'ctools-no-js';
  132. $class .= ($is_drop_button) ? ' ctools-dropbutton' : '';
  133. $class .= ' ctools-button';
  134. if (!empty($variables['class'])) {
  135. $class .= ($variables['class']) ? (' ' . implode(' ', $variables['class'])) : '';
  136. }
  137. $output = '';
  138. $output .= '<div class="' . $class . '" id="ctools-button-' . $id . '">';
  139. // Add a twisty if this is a dropbutton
  140. if ($is_drop_button) {
  141. $variables['title'] = ($variables['title'] ? check_plain($variables['title']) : t('open'));
  142. $output .= '<div class="ctools-link">';
  143. if ($variables['image']) {
  144. $output .= '<a href="#" class="ctools-twisty ctools-image">' . $variables['title'] . '</a>';
  145. }
  146. else {
  147. $output .= '<a href="#" class="ctools-twisty ctools-text">' . $variables['title'] . '</a>';
  148. }
  149. $output .= '</div>'; // ctools-link
  150. }
  151. // The button content
  152. $output .= '<div class="ctools-content">';
  153. // Check for attributes. theme_links expects an array().
  154. $variables['attributes'] = (!empty($variables['attributes'])) ? $variables['attributes'] : array();
  155. // Remove the inline and links classes from links if they exist.
  156. // These classes are added and styled by Drupal core and mess up the default
  157. // styling of any link list.
  158. if (!empty($variables['attributes']['class'])) {
  159. $classes = $variables['attributes']['class'];
  160. foreach ($classes as $key => $class) {
  161. if ($class === 'inline' || $class === 'links') {
  162. unset($variables['attributes']['class'][$key]);
  163. }
  164. }
  165. }
  166. // Call theme_links to render the list of links.
  167. $output .= theme_links(array('links' => $variables['links'], 'attributes' => $variables['attributes'], 'heading' => ''));
  168. $output .= '</div>'; // ctools-content
  169. $output .= '</div>'; // ctools-dropbutton
  170. // Wrap the output in our container.
  171. $output = '<div class="ctools-dropbutton-wrapper">' . $output . '</div>';
  172. return $output;
  173. }
  174. else {
  175. return '';
  176. }
  177. }
  178. /**
  179. * Implements hook_views_ui_display_tab_alter().
  180. *
  181. * This is used to wrap span tags around title components in the Fields section
  182. * of the Views Admin UI.
  183. *
  184. * @see views_ui_edit_form_get_bucket()
  185. */
  186. function ember_views_ui_display_tab_alter(&$build, &$view, $display_id) {
  187. // First check that the setting is enabled.
  188. if (theme_get_setting('views_ui_override') == FALSE) {
  189. // Do nothing if the setting is not enabled.
  190. return;
  191. }
  192. $display = $view->display[$display_id];
  193. $root_url = "admin/structure/views/nojs/config-item/$view->name/$display_id";
  194. // The below is a straight copy-paste from views_ui_edit_form_get_bucket().
  195. static $relationships = NULL;
  196. if (!isset($relationships)) {
  197. // Get relationship labels.
  198. $relationships = array();
  199. // @todo: get_handlers()
  200. $handlers = $display->handler->get_option('relationships');
  201. if ($handlers) {
  202. foreach ($handlers as $id => $info) {
  203. $handler = $display->handler->get_handler('relationship', $id);
  204. $relationships[$id] = $handler->label();
  205. }
  206. }
  207. }
  208. // Custom code begins.
  209. // For each type of field which may have a description, alter the link text.
  210. $type = 'field';
  211. foreach ($display->handler->get_option("{$type}s") as $id => $field) {
  212. $handler = $display->handler->get_handler($type, $id);
  213. $text = _ember_views_ui_field_link($field, $handler, $relationships, $type, $root_url);
  214. $build['details']['columns']['first']['fields']['fields'][$id]['#link'] = $text;
  215. }
  216. $type = 'argument';
  217. foreach ($display->handler->get_option("{$type}s") as $id => $field) {
  218. $handler = $display->handler->get_handler($type, $id);
  219. $text = _ember_views_ui_field_link($field, $handler, $relationships, $type, $root_url);
  220. $build['details']['columns']['third']['collapse']['arguments']['fields'][$id]['#link'] = $text;
  221. }
  222. $type = 'relationship';
  223. foreach ($display->handler->get_option("{$type}s") as $id => $field) {
  224. $handler = $display->handler->get_handler($type, $id);
  225. $text = _ember_views_ui_field_link($field, $handler, $relationships, $type, $root_url);
  226. $build['details']['columns']['third']['collapse']['relationships']['fields'][$id]['#link'] = $text;
  227. }
  228. }
  229. /**
  230. * Generate a field description and link for the Views UI.
  231. *
  232. * @param object $field
  233. * The field we wish to edit output for.
  234. * @param object $handler
  235. * The field handler (a views API component).
  236. * @param array $relationships
  237. * An array of relationships, in the format field_id=>relationship name.
  238. * @param string $type
  239. * The type of field, either field, argument, or relationship.
  240. * @param string $root_url
  241. * The root url to the Views AJAX interface. This function suffixes it.
  242. *
  243. * @return string
  244. * An a tag with HTML inside which splits the link text into components.
  245. */
  246. function _ember_views_ui_field_link($field, $handler, array $relationships, $type, $root_url) {
  247. // If an administrative title is set, use that for anchor text.
  248. if (isset($field['ui_name']) && trim($field['ui_name']) !== '') {
  249. $link_text = $field['ui_name'];
  250. }
  251. // Otherwise, build up some structured anchor text.
  252. else {
  253. // Split out the title into its components.
  254. // @see views_handler_field::ui_name()
  255. // Add the new field descriptions to the output, replacing the default.
  256. $new_label = "<span class='views-field-entity-type'>{$handler->definition['group']}:</span>";
  257. $new_label .= "<span class='views-field-title'>{$handler->definition['title']}</span> ";
  258. if (!empty($field['relationship']) && !empty($relationships[$field['relationship']])) {
  259. $new_label .= "<span class='views-field-relationship'>{$relationships[$field['relationship']]}</span>";
  260. }
  261. // Reuse some code from the parent function to build up the link again.
  262. $description = filter_xss_admin($handler->admin_summary());
  263. $link_text = $new_label . (empty($description) ? '' : "<span class='views-field-label'>($description)</span>");
  264. }
  265. $link_text = "<div class='views-field-description'>{$link_text}</div>";
  266. $link_attributes = array('class' => array('views-ajax-link'));
  267. if (!empty($field['exclude'])) {
  268. $link_attributes['class'][] = 'views-field-excluded';
  269. }
  270. return l($link_text,
  271. "$root_url/$type/{$field['id']}",
  272. array('attributes' => $link_attributes, 'html' => TRUE)
  273. );
  274. }