omega.theme.inc

  1. cis7 sites/all/themes/ulmus/omega/omega/includes/omega.theme.inc
  2. cle7 sites/all/themes/ulmus/omega/omega/includes/omega.theme.inc
  3. ecd7 sites/all/themes/ulmus/omega/omega/includes/omega.theme.inc
  4. elmsmedia7 sites/all/themes/ulmus/omega/omega/includes/omega.theme.inc
  5. harmony7 sites/all/themes/ulmus/omega/omega/includes/omega.theme.inc
  6. icor7 sites/all/themes/ulmus/omega/omega/includes/omega.theme.inc
  7. meedjum_blog7 sites/all/themes/ulmus/omega/omega/includes/omega.theme.inc
  8. mooc7 sites/all/themes/ulmus/omega/omega/includes/omega.theme.inc

Functions

Namesort descending Description
omega_item_list Implements hook_item_list().
omega_links Implements hook_links().
omega_menu_local_task Implements hook_menu_local_task().
omega_menu_local_tasks Implements hook_menu_local_tasks().
omega_pager Returns HTML for a query pager.
omega_views_mini_pager Implements hook_views_mini_pager().

File

sites/all/themes/ulmus/omega/omega/includes/omega.theme.inc
View source
  1. <?php
  2. /**
  3. * Returns HTML for a query pager.
  4. *
  5. * Menu callbacks that display paged query results should call theme('pager') to
  6. * retrieve a pager control so that users can view other results. Format a list
  7. * of nearby pages with additional query results.
  8. *
  9. * @param $vars
  10. * An associative array containing:
  11. * - tags: An array of labels for the controls in the pager.
  12. * - element: An optional integer to distinguish between multiple pagers on
  13. * one page.
  14. * - parameters: An associative array of query string parameters to append to
  15. * the pager links.
  16. * - quantity: The number of pages in the list.
  17. *
  18. * @ingroup themeable
  19. */
  20. function omega_pager($vars) {
  21. global $pager_page_array, $pager_total;
  22. $tags = $vars['tags'];
  23. $element = $vars['element'];
  24. $parameters = $vars['parameters'];
  25. $quantity = $vars['quantity'];
  26. // Calculate various markers within this pager piece:
  27. // Middle is used to "center" pages around the current page.
  28. $pager_middle = ceil($quantity / 2);
  29. // current is the page we are currently paged to
  30. $pager_current = $pager_page_array[$element] + 1;
  31. // first is the first page listed by this pager piece (re quantity)
  32. $pager_first = $pager_current - $pager_middle + 1;
  33. // last is the last page listed by this pager piece (re quantity)
  34. $pager_last = $pager_current + $quantity - $pager_middle;
  35. // max is the maximum page number
  36. $pager_max = $pager_total[$element];
  37. // End of marker calculations.
  38. // Prepare for generation loop.
  39. $i = $pager_first;
  40. if ($pager_last > $pager_max) {
  41. // Adjust "center" if at end of query.
  42. $i = $i + ($pager_max - $pager_last);
  43. $pager_last = $pager_max;
  44. }
  45. if ($i <= 0) {
  46. // Adjust "center" if at start of query.
  47. $pager_last = $pager_last + (1 - $i);
  48. $i = 1;
  49. }
  50. // End of generation loop preparation.
  51. $li_first = theme('pager_first', array('text' => (isset($tags[0]) ? $tags[0] : t('« first')), 'element' => $element, 'parameters' => $parameters));
  52. $li_previous = theme('pager_previous', array('text' => (isset($tags[1]) ? $tags[1] : t('‹ previous')), 'element' => $element, 'interval' => 1, 'parameters' => $parameters));
  53. $li_next = theme('pager_next', array('text' => (isset($tags[3]) ? $tags[3] : t('next ›')), 'element' => $element, 'interval' => 1, 'parameters' => $parameters));
  54. $li_last = theme('pager_last', array('text' => (isset($tags[4]) ? $tags[4] : t('last »')), 'element' => $element, 'parameters' => $parameters));
  55. if ($pager_total[$element] > 1) {
  56. if ($li_first) {
  57. $items[] = array(
  58. 'class' => array('pager-first'),
  59. 'data' => $li_first,
  60. );
  61. }
  62. if ($li_previous) {
  63. $items[] = array(
  64. 'class' => array('pager-previous'),
  65. 'data' => $li_previous,
  66. );
  67. }
  68. // When there is more than one page, create the pager list.
  69. if ($i != $pager_max) {
  70. if ($i > 1) {
  71. $items[] = array(
  72. 'class' => array('pager-ellipsis'),
  73. 'data' => '…',
  74. );
  75. }
  76. // Now generate the actual pager piece.
  77. for (; $i <= $pager_last && $i <= $pager_max; $i++) {
  78. if ($i < $pager_current) {
  79. $items[] = array(
  80. 'class' => array('pager-item'),
  81. 'data' => theme('pager_previous', array('text' => $i, 'element' => $element, 'interval' => ($pager_current - $i), 'parameters' => $parameters)),
  82. );
  83. }
  84. if ($i == $pager_current) {
  85. $items[] = array(
  86. 'class' => array('pager-current'),
  87. 'data' => $i,
  88. );
  89. }
  90. if ($i > $pager_current) {
  91. $items[] = array(
  92. 'class' => array('pager-item'),
  93. 'data' => theme('pager_next', array('text' => $i, 'element' => $element, 'interval' => ($i - $pager_current), 'parameters' => $parameters)),
  94. );
  95. }
  96. }
  97. if ($i < $pager_max) {
  98. $items[] = array(
  99. 'class' => array('pager-ellipsis'),
  100. 'data' => '…',
  101. );
  102. }
  103. }
  104. // End generation.
  105. if ($li_next) {
  106. $items[] = array(
  107. 'class' => array('pager-next'),
  108. 'data' => $li_next,
  109. );
  110. }
  111. if ($li_last) {
  112. $items[] = array(
  113. 'class' => array('pager-last'),
  114. 'data' => $li_last,
  115. );
  116. }
  117. return '<h2 class="element-invisible">' . t('Pages') . '</h2>' . theme('item_list', array(
  118. 'items' => $items,
  119. 'attributes' => array('class' => array('pager', 'clearfix')),
  120. ));
  121. }
  122. }
  123. /**
  124. * Implements hook_item_list().
  125. */
  126. function omega_item_list($vars) {
  127. $items = $vars['items'];
  128. $title = $vars['title'];
  129. $type = $vars['type'];
  130. $attributes = $vars['attributes'];
  131. $output = '<div class="item-list">';
  132. if (isset($title)) {
  133. $output .= '<h3>' . $title . '</h3>';
  134. }
  135. if (!empty($items)) {
  136. $output .= "<$type" . drupal_attributes($attributes) . '>';
  137. $num_items = count($items);
  138. foreach ($items as $i => $item) {
  139. $attributes = array();
  140. $children = array();
  141. if (is_array($item)) {
  142. foreach ($item as $key => $value) {
  143. if ($key == 'data') {
  144. $data = $value;
  145. }
  146. elseif ($key == 'children') {
  147. $children = $value;
  148. }
  149. else {
  150. $attributes[$key] = $value;
  151. }
  152. }
  153. }
  154. else {
  155. $data = $item;
  156. }
  157. if (count($children) > 0) {
  158. // Render nested list.
  159. $data .= theme_item_list(array('items' => $children, 'title' => NULL, 'type' => $type, 'attributes' => $attributes));
  160. }
  161. if ($i == 0) {
  162. $attributes['class'][] = 'first';
  163. }
  164. if ($i == $num_items - 1) {
  165. $attributes['class'][] = 'last';
  166. }
  167. $output .= '<li' . drupal_attributes($attributes) . '>' . $data . "</li>";
  168. }
  169. $output .= "</$type>";
  170. }
  171. $output .= '</div>';
  172. return $output;
  173. }
  174. /**
  175. * Implements hook_views_mini_pager().
  176. *
  177. * This custom theming for views_mini_pager changes the previous/next
  178. * links to remove theme completely when not present to avoid the
  179. * &nbsp; messing up the spacing/theming in the list.
  180. */
  181. function omega_views_mini_pager($vars) {
  182. global $pager_page_array, $pager_total;
  183. $tags = $vars['tags'];
  184. $element = $vars['element'];
  185. $parameters = $vars['parameters'];
  186. $quantity = $vars['quantity'];
  187. // Calculate various markers within this pager piece:
  188. // Middle is used to "center" pages around the current page.
  189. $pager_middle = ceil($quantity / 2);
  190. // current is the page we are currently paged to
  191. $pager_current = $pager_page_array[$element] + 1;
  192. // max is the maximum page number
  193. $pager_max = $pager_total[$element];
  194. // End of marker calculations.
  195. $li_previous = theme('pager_previous',
  196. array(
  197. 'text' => (isset($tags[1]) ? $tags[1] : t('‹‹')),
  198. 'element' => $element,
  199. 'interval' => 1,
  200. 'parameters' => $parameters,
  201. )
  202. );
  203. if (empty($li_previous)) {
  204. $li_previous = "";
  205. }
  206. $li_next = theme('pager_next',
  207. array(
  208. 'text' => (isset($tags[3]) ? $tags[3] : t('››')),
  209. 'element' => $element,
  210. 'interval' => 1,
  211. 'parameters' => $parameters,
  212. )
  213. );
  214. if (empty($li_next)) {
  215. $li_next = "";
  216. }
  217. if ($pager_total[$element] > 1) {
  218. $items[] = array(
  219. 'class' => array('pager-previous'),
  220. 'data' => $li_previous,
  221. );
  222. $items[] = array(
  223. 'class' => array('pager-current'),
  224. 'data' => t('@current of @max', array('@current' => $pager_current, '@max' => $pager_max)),
  225. );
  226. $items[] = array(
  227. 'class' => array('pager-next'),
  228. 'data' => $li_next,
  229. );
  230. return theme('item_list',
  231. array(
  232. 'items' => $items,
  233. 'title' => NULL,
  234. 'type' => 'ul',
  235. 'attributes' => array('class' => array('pager')),
  236. )
  237. );
  238. }
  239. }
  240. /**
  241. * Implements hook_links().
  242. */
  243. function omega_links($vars) {
  244. global $language_url;
  245. $links = $vars['links'];
  246. $attributes = $vars['attributes'];
  247. $heading = $vars['heading'];
  248. $output = '';
  249. if (count($links) > 0) {
  250. // Treat the heading first if it is present to prepend it to the list of links.
  251. if (!empty($heading)) {
  252. if (is_string($heading)) {
  253. // Prepare the array that will be used when the passed heading is a string.
  254. $heading = array(
  255. 'text' => $heading,
  256. // Set the default level of the heading.
  257. 'level' => 'h2',
  258. );
  259. }
  260. $output .= '<' . $heading['level'];
  261. if (!empty($heading['class'])) {
  262. $output .= drupal_attributes(array('class' => $heading['class']));
  263. }
  264. $output .= '>' . check_plain($heading['text']) . '</' . $heading['level'] . '>';
  265. }
  266. $output .= '<ul' . drupal_attributes($attributes) . '>';
  267. $num_links = count($links);
  268. $i = 1;
  269. foreach ($links as $key => $link) {
  270. $class = array($key);
  271. // Add first, last and active classes to the list of links to help out themers.
  272. if ($i == 1) {
  273. $class[] = 'first';
  274. }
  275. if ($i == $num_links) {
  276. $class[] = 'last';
  277. }
  278. if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page())) && (empty($link['language']) || $link['language']->language == $language_url->language)) {
  279. $class[] = 'active';
  280. }
  281. // Add a class for has a sub-menu
  282. if(isset($link['below'])) {
  283. $class[] = 'has-subitems';
  284. }
  285. $output .= '<li' . drupal_attributes(array('class' => $class)) . '>';
  286. if (isset($link['href'])) {
  287. // Pass in $link as $options, they share the same keys.
  288. $output .= l(trim($link['title']), $link['href'], $link);
  289. }
  290. elseif (!empty($link['title'])) {
  291. // Some links are actually not links, but we wrap these in <span> for adding title and class attributes.
  292. if (empty($link['html'])) {
  293. $link['title'] = check_plain($link['title']);
  294. }
  295. $span_attributes = '';
  296. if (isset($link['attributes'])) {
  297. $span_attributes = drupal_attributes($link['attributes']);
  298. }
  299. $output .= '<span' . $span_attributes . '>' . $link['title'] . '</span>';
  300. }
  301. // Theme in nested links in the UL
  302. if(isset($link['below'])) {
  303. $output .= theme('links', array(
  304. 'links' => $link['below'],
  305. 'attributes' => array(
  306. 'class' => array('links', 'main-menu', 'secondary-items'),
  307. ),
  308. ));
  309. }
  310. $i++;
  311. $output .= "</li>";
  312. }
  313. $output .= '</ul>';
  314. }
  315. return $output;
  316. }
  317. /**
  318. * Implements hook_menu_local_tasks().
  319. */
  320. function omega_menu_local_tasks(&$vars) {
  321. $output = '';
  322. if (!empty($vars['primary'])) {
  323. $vars['primary']['#prefix'] = '<h2 class="element-invisible">' . t('Primary tabs') . '</h2>';
  324. $vars['primary']['#prefix'] .= '<ul class="tabs primary clearfix">';
  325. $vars['primary']['#suffix'] = '</ul>';
  326. $output .= drupal_render($vars['primary']);
  327. }
  328. if (!empty($vars['secondary'])) {
  329. $vars['secondary']['#prefix'] = '<h2 class="element-invisible">' . t('Secondary tabs') . '</h2>';
  330. $vars['secondary']['#prefix'] .= '<ul class="tabs secondary clearfix">';
  331. $vars['secondary']['#suffix'] = '</ul>';
  332. $output .= drupal_render($vars['secondary']);
  333. }
  334. return $output;
  335. }
  336. /**
  337. * Implements hook_menu_local_task().
  338. */
  339. function omega_menu_local_task($vars) {
  340. $link = $vars['element']['#link'];
  341. $link_text = $link['title'];
  342. if (!empty($vars['element']['#active'])) {
  343. // Add text to indicate active tab for non-visual users.
  344. $active = '<span class="element-invisible">' . t('(active tab)') . '</span>';
  345. // If the link does not contain HTML already, check_plain() it now.
  346. // After we set 'html'=TRUE the link will not be sanitized by l().
  347. if (empty($link['localized_options']['html'])) {
  348. $link['title'] = check_plain($link['title']);
  349. }
  350. $link['localized_options']['html'] = TRUE;
  351. $link_text = t('!local-task-title!active', array('!local-task-title' => $link['title'], '!active' => $active));
  352. }
  353. return '<li' . (!empty($vars['element']['#active']) ? ' class="active"' : '') . '>' . l($link_text, $link['href'], $link['localized_options']) . "</li>";
  354. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.