' . $primary . ''; } elseif ($primary) { $output .= ''; } if ($secondary) { $output .= ''; } return $output; } /** * Override or insert variables into all templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered (name of the .tpl.php file.) */ /* -- Delete this line if you want to use this function function zuitedesk_preprocess(&$vars, $hook) { $vars['sample_variable'] = t('Lorem ipsum.'); } // */ /** * Override or insert variables into the page templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("page" in this case.) */ function zuitedesk_preprocess_page(&$vars, $hook) { global $user; $vars['html_attributes'] = 'lang="' . $vars['language']->language . '" dir="' . $vars['language']->dir . '"'; // Remove duplicate utf-8 meta tag. $vars['head'] = preg_replace('/]*>\n/', '', $vars['head']); // Remove pre-navigation links in header. $vars['head'] = preg_replace('/]*>\n/', '', $vars['head']); // Refine title; suffix for public (U+00B0), authorised (U+207B) and private (U+00AA) nodes: if (!$vars['logged_in']) { $vars['head_title'] = t('Welcome to @site_name', array('@site_name' => $vars['site_name'] ? $vars['site_name'] : 'SuiteDesk')); } elseif ($vars['head_title'] == 'SuiteDesk - SuiteDesk') { $vars['head_title'] = 'SuiteDesk'; } else { $vars['head_title'] = str_replace(array('°', 'ª', '⁻'), '', $vars['head_title']); } // Body class for node clone: if (is_numeric(arg(1)) && arg(2) == 'clone' && arg(3) == '') { $vars['classes_array'][] = 'section-node-clone'; } // We need to re-do the $layout and body classes because // template_preprocess_page() assumes sidebars are named 'left' and 'right'. if (!empty($vars['sidebar_main'])) { $vars['layout'] = 'main'; $vars['classes_array'] = array_diff($vars['classes_array'], array('no-sidebars')); $vars['classes_array'][] = 'sidebar-main'; } // Main menu: primary links. $lang = $vars['language']->language != 'es' ? '/' . $vars['language']->language : ''; $home = $vars['language']->language != 'es' ? '/' . $vars['language']->language : '/'; $deskmenu = $_SESSION['deskmenu']; $pl = ''; if ($vars['logged_in'] && !empty($deskmenu)) { // Home option: $pl .= _zuitedesk_option(TRUE, "$home", t('Home'), 'home', NULL, t('Desktop')); // CRM submenu: $submenu = ''; $submenu .= _zuitedesk_option(!empty($_SESSION['SuiteCRM_Session_ID']), "$lang/suitecrm", 'SuiteCRM', 'suitecrm', 'crm', t('Core sales, customer service and marketing processes with SuiteCRM')); $submenu .= _zuitedesk_option($deskmenu[3], "$lang/organizations", t('Organizations'), 'org', 'org'); $partial = ''; $partial .= _zuitedesk_option($deskmenu[1], "$lang/admin/user/user/local", t('User list'), 'userlist', 'login', t('Allows to view list users and register new users')); $partial .= _zuitedesk_option($deskmenu[4], "$lang/people", t('People'), 'people', 'people'); $partial .= _zuitedesk_option($deskmenu[5], "$lang/teams", t('Teams'), 'teams', 'team'); $submenu .= _zuitedesk_divider($submenu, $partial); $partial = ''; $partial .= _zuitedesk_option(FALSE, "$lang/activity", t('Activity'), 'activity', 'eye'); $submenu .= _zuitedesk_divider($submenu, $partial); $pl .= _zuitedesk_submenu($submenu, t('Contacts'), 'contacts'); // Plan submenu: $submenu = ''; $submenu .= _zuitedesk_option($deskmenu[6], "$lang/projects", t('Projects'), 'projects', 'project'); $submenu .= _zuitedesk_option($deskmenu[7], "$lang/tasks", t('Tasks'), 'tasks', 'task'); $submenu .= _zuitedesk_option($deskmenu[8], "$lang/tasks/kanban", t('Tasks Kanban'), 'kanban', 'kanban', t('Kanban board view for your tasks')); $partial = ''; $partial .= _zuitedesk_option($deskmenu[9], "$lang/events", t('Events'), 'events', 'event'); $partial .= _zuitedesk_option($deskmenu[9], "$lang/calendar", t('Calendar'), 'calendar', 'calendar'); $submenu .= _zuitedesk_divider($submenu, $partial); $partial = ''; $partial .= _zuitedesk_option($deskmenu[10], "$lang/doks", t('Documentation'), 'dok', 'doc'); $partial .= _zuitedesk_option($deskmenu[10], "$lang/lexicon", t('Glossary'), 'glossary', 'glossary'); $submenu .= _zuitedesk_divider($submenu, $partial); $pl .= _zuitedesk_submenu($submenu, t('Plan'), 'plan'); // Assistance submenu: $submenu = ''; $submenu .= _zuitedesk_option($deskmenu[13], "$lang/tickets", t('Tickets'), 'tickets', 'ticket'); $partial = ''; $partial .= _zuitedesk_option($deskmenu[14], "$lang/expenses", t('Expenses'), 'expenses', 'expense'); $partial .= _zuitedesk_option($deskmenu[15], "$lang/invoices", t('Invoices'), 'invoices', 'invoice'); $partial .= _zuitedesk_option($deskmenu[16], "$lang/timetrackings", t('Timetrackings'), 'timetracking', 'timetracking'); $submenu .= _zuitedesk_divider($submenu, $partial); $partial = ''; $partial .= _zuitedesk_option($deskmenu[2], "$lang/attributes", t('Attributes'), 'attributes', 'filter'); $partial .= _zuitedesk_option($deskmenu[2], "$lang/admin/settings/suitedesk", t('Configuration'), 'settings', 'storm'); $submenu .= _zuitedesk_divider($submenu, $partial); $partial = ''; $partial .= _zuitedesk_option($deskmenu[18], "$lang/trash", t('Trash'), 'trash', 'trash'); $partial .= _zuitedesk_option(TRUE, '', t('SuiteDesk Tour'), 'help', 'help', t('A beginner\'s guide to SuiteDesk')); $partial .= _zuitedesk_option(TRUE, "$lang/search", t('Advanced search'), 'search', 'search'); $submenu .= _zuitedesk_divider($submenu, $partial); $pl .= _zuitedesk_submenu($submenu, t('Assistance'), 'assistance'); // User submenu: $submenu = ''; $submenu .= _zuitedesk_option($deskmenu[11], "$lang/notes", t('My notes'), 'notes', 'note'); $submenu .= _zuitedesk_option($deskmenu[12], "$lang/ideas", t('Reminders'), 'ideas', 'idea'); $submenu .= _zuitedesk_option($deskmenu[17], "$lang/user/watcher", t('Watcher'), 'watcher', 'apply'); $partial = ''; $partial .= _zuitedesk_option(TRUE, "$lang/" . drupal_get_path_alias('user/' . $user->uid) . '/edit', t('My SuiteDesk profile'), 'profile', 'user', t('Edit my personal account options')); $partial .= _zuitedesk_option(TRUE, "$lang/logout", t('Logout'), 'logout', 'logout', t('Close your session')); $submenu .= _zuitedesk_divider($submenu, $partial); $user_name = !empty($user->picture) ? '
' . $user->name . '
' : ''; $firstname = strpos($user->name, ' '); $user_name .= $firstname === FALSE ? $user->name : substr($user->name, 0, $firstname); $pl .= _zuitedesk_submenu($submenu, $user_name, 'user'); } else { $pl = _zuitedesk_option(TRUE, "$lang/user/login", t('Login') . ' ', 'login', NULL, t('New session for authenticated users')); } $vars['primary_links'] = '

' . t('Main menu') . '

'; $vars['primary_links'] .= ''; // Social menu: secondary links. if (user_is_anonymous() || empty($_SESSION['socialmenu'])) { $sl = ''; $sl .= _zuitedesk_social_link('social_website', t('Website'), 'www'); $sl .= _zuitedesk_social_link('social_rss', 'Rss', 'rss'); $sl .= _zuitedesk_social_link('social_twitter', 'Twitter', 'twitter'); $sl .= _zuitedesk_social_link('social_facebook', 'Facebook', 'facebook'); $sl .= _zuitedesk_social_link('social_linkedin', 'Linkedin', 'linkedin'); $sl .= _zuitedesk_social_link('social_github', 'Github', 'github'); $sl .= _zuitedesk_social_link('social_gitlab', 'Gitlab', 'gitlab'); $sl .= _zuitedesk_social_link('social_contact', 'Mail', 'mail'); $_SESSION['socialmenu'] = $sl; } $vars['secondary_links'] = $_SESSION['socialmenu']; // Special class and bootstrap tour for SuiteDesk pages: $vars['classes_array'][] = 'suitedesk'; // Node vars. if (!empty($vars['node'])) { $node = $vars['node']; // Remove the class for node type. $vars['classes_array'] = array_diff($vars['classes_array'], array(drupal_html_class('node-type-' . $node->type))); // Javascript to confirm projects cloning. if ($vars['node']->type == 'stormproject' && user_access('Storm project: clone projects')) { drupal_add_js('(function($) {$("li.stormproject_clone_run a").on("click", function() {return confirm("' . t('WARNING! This operation will duplicate all the project, tasks and documents in book. Are you sure?') . '");});})($jq);', 'inline', 'footer', FALSE); $vars['closure'] .= drupal_get_js('footer'); } } // Guided tour for authenticated users: if (user_is_logged_in()) { $tour = 'tourmenu'; drupal_add_js(drupal_get_path('theme', 'zuitedesk') . "/js/$tour.js", 'theme', 'footer', FALSE); } } function _zuitedesk_option($access, $url, $text, $id = NULL, $icon = NULL, $message = NULL) { $option = ''; if ($access) { $option .= empty($id) ? '
  • ' : '
  • '; } return $option; } function _zuitedesk_divider(&$submenu, &$partial) { return !empty($submenu) && !empty($partial) ? '
  • ' . $partial : $partial; } function _zuitedesk_submenu(&$submenu, $text, $id = NULL) { $options = ''; if (!empty($submenu)) { $options .= empty($id) ? ''; } return $options; } function _zuitedesk_social_link($social_field, $title, $class) { global $conf; $link = ''; $social_link = variable_get($social_field, $conf[$social_field]); if (!empty($social_link)) { $link .= ''; } return $link; } /** * Override or insert variables into the node templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("node" in this case.) */ function zuitedesk_preprocess_node(&$vars, $hook) { if (in_array($vars['type'], array('blog', 'note', 'photo')) && $vars['page']) { $vars['display_submitted'] = FALSE; } else { $node = $vars['node']; $published = $node->created; if ($node->published > $node->created && substr($vars['type'], 0, 5) != 'storm') { $published = $node->published; } $vars['submitted'] = t('Submitted by !username on @datetime', array( '!username' => theme('username', $node), '@datetime' => format_date($published, 'small'), )); } /* $vars['sample_variable'] = t('Lorem ipsum.'); // Optionally, run node-type-specific preprocess functions, like // zuitedesk_preprocess_node_page() or zuitedesk_preprocess_node_story(). $function = __FUNCTION__ . '_' . $vars['node']->type; if (function_exists($function)) { $function($vars, $hook); } */ } /** * Override or insert variables into the comment templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("comment" in this case.) */ /* -- Delete this line if you want to use this function function zuitedesk_preprocess_comment(&$vars, $hook) { $vars['sample_variable'] = t('Lorem ipsum.'); } // */ /** * Override or insert variables into the block templates. * * @param $vars * An array of variables to pass to the theme template. * @param $hook * The name of the template being rendered ("block" in this case.) */ /* -- Delete this line if you want to use this function function zuitedesk_preprocess_block(&$vars, $hook) { $vars['sample_variable'] = t('Lorem ipsum.'); } // */ /** * Override theme_breadcrumb(). */ function zuitedesk_breadcrumb($breadcrumb) { // When no breadcrumb: if (count($breadcrumb) == 0) { return ''; } // No breadcrumb in home page and others: if (in_array(arg(0), array('user', 'search', 'ideas'))) { return ''; } // No breadcrumb if it's only one link to home page: if (count($breadcrumb) == 1 && strpos($breadcrumb[0], '>' . t('Home') . '<') > 0) { return ''; } return ''; } /** * Override theme_more_help_link(). */ function zuitedesk_more_help_link($url) { global $user; return $user->uid == 1 ? '' : ''; } /** * Override theme_imagecache() function of imagecache module. */ function zuitedesk_imagecache($presetname, $path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE, $absolute = TRUE) { if ($presetname == 'attached' || $presetname == 'maxiphoto') { $attributes['class'] .= ' img-responsive'; } return theme_imagecache($presetname, $path, $alt, $title, $attributes, $getsize, $absolute); } /** * Override theme_button(). * * See http://designguru.org/blog/040612/replacing-drupal-form-submission-inputs-allow-cufon-styling */ function zuitedesk_button($element) { // Make sure not to overwrite classes. if (isset($element['#attributes']['class'])) { $element['#attributes']['class'] = 'form-' . $element['#button_type'] . ' ' . $element['#attributes']['class']; } else { $element['#attributes']['class'] = 'form-' . $element['#button_type']; } $value = check_plain($element['#value']); $element['#attributes']['class'] .= _zuitedesk_button_classes($value); return ''; } /** * Override theme_select(). */ function zuitedesk_select($element) { _form_set_class($element, array('form-control')); return theme_select($element); } /** * Override theme_textfield(). */ function zuitedesk_textfield($element) { _form_set_class($element, array('form-control')); return theme_textfield($element); } /** * Override theme_password(). */ function zuitedesk_password($element) { _form_set_class($element, array('form-control')); return theme_password($element); } /** * Override theme_textarea(). */ function zuitedesk_textarea($element) { _form_set_class($element, array('form-control')); return theme_textarea($element); } /** * Override theme_webform_email(). */ function zuitedesk_webform_email($element) { _form_set_class($element, array('form-control')); return theme_webform_email($element); } /** * Override theme_checkbox(). */ function zuitedesk_checkbox($element) { if (isset($element['#title'])) { $element['#title'] = t($element['#title']); } return theme_checkbox($element); } /** * Override theme_radio(). */ function zuitedesk_radio($element) { if (isset($element['#title'])) { $element['#title'] = t($element['#title']); } return theme_radio($element); } /** * Override theme_table(). */ function zuitedesk_table($header, $rows, $attributes = array(), $caption = NULL) { if (!in_array($attributes['id'], array('tasks'))) { $attributes['class'] = 'table table-condensed' . (!empty($attributes['class']) ? ' ' . $attributes['class'] : ''); } if (arg(0) == 'admin' || substr($attributes['id'], 0, 5) == 'storm' || in_array($attributes['id'], array('attributes', 'tasks', 'twatcher'))) { $attributes['class'] .= (empty($attributes['class']) ? '' : ' ') . 'table-hover'; return '
    ' . theme_table($header, $rows, $attributes, $caption) . '
    '; } return theme_table($header, $rows, $attributes, $caption); } /** * Override theme_pager(). */ function zuitedesk_pager($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 9) { global $pager_page_array, $pager_total; // Calculate various markers within this pager piece: // Middle is used to "center" pages around the current page. $pager_middle = ceil($quantity / 2); // current is the page we are currently paged to $pager_current = $pager_page_array[$element] + 1; // first is the first page listed by this pager piece (re quantity) $pager_first = $pager_current - $pager_middle + 1; // last is the last page listed by this pager piece (re quantity) $pager_last = $pager_current + $quantity - $pager_middle; // max is the maximum page number $pager_max = $pager_total[$element]; // End of marker calculations. // Prepare for generation loop. $i = $pager_first; if ($pager_last > $pager_max) { // Adjust "center" if at end of query. $i = $i + ($pager_max - $pager_last); $pager_last = $pager_max; } if ($i <= 0) { // Adjust "center" if at start of query. $pager_last = $pager_last + (1 - $i); $i = 1; } // End of generation loop preparation. // Special use for kanban tasks page (optimized for performace): if ($_GET['q'] == 'tasks/kanban') { $view = views_get_current_view(); if (!empty($view) && $view->name == 'storm_projects_kanban' && $view->current_display == 'page_2') { if (empty($_REQUEST['go'])) { $parameters['go'] = 'backlog'; } else { drupal_add_js('$jq(function(){$(\'html,body\').animate({scrollTop:$("#views-exposed-form-storm-projects-kanban-page-2").offset().top-60},1600);});', 'inline', 'footer'); } } } $li_first = theme('pager_first', (isset($tags[0]) ? $tags[0] : '«'), $limit, $element, $parameters); $li_previous = theme('pager_previous', (isset($tags[1]) ? $tags[1] : '‹'), $limit, $element, 1, $parameters); $li_next = theme('pager_next', (isset($tags[3]) ? $tags[3] : '›'), $limit, $element, 1, $parameters); $li_last = theme('pager_last', (isset($tags[4]) ? $tags[4] : '»'), $limit, $element, $parameters); if ($pager_total[$element] > 1) { if ($li_first) { $items[] = array( // 'class' => 'pager-first', 'data' => $li_first, ); } if ($li_previous) { $items[] = array( // 'class' => 'pager-previous', 'data' => $li_previous, ); } // When there is more than one page, create the pager list. if ($i != $pager_max) { # if ($i > 1) { # $items[] = array( # 'class' => 'disabled', # 'data' => '', # ); # } // Now generate the actual pager piece. for (; $i <= $pager_last && $i <= $pager_max; $i++) { if ($i < $pager_current) { $items[] = array( // 'class' => 'pager-item', 'data' => theme('pager_previous', $i, $limit, $element, ($pager_current - $i), $parameters), ); } if ($i == $pager_current) { $items[] = array( 'class' => 'active', 'data' => "$i", ); } if ($i > $pager_current) { $items[] = array( // 'class' => 'pager-item', 'data' => theme('pager_next', $i, $limit, $element, ($i - $pager_current), $parameters), ); } } # if ($i < $pager_max) { # $items[] = array( # 'class' => 'disabled', # 'data' => '', # ); # } } // End generation. if ($li_next) { $items[] = array( // 'class' => 'pager-next', 'data' => $li_next, ); } if ($li_last) { $items[] = array( // 'class' => 'pager-last', 'data' => $li_last, ); } return theme('item_list', $items, NULL, 'ul', array('class' => 'pagination')); } } function _zuitedesk_button_classes($value) { // Text values containing these strings. $button_strings = array( 'btn-danger' => array( t('Delete'), t('Remove'), t('Move to trash'), ), 'btn-primary' => array( t('Login'), t('Log in'), t('Save'), t('Confirm'), t('Submit'), t('Search'), t('Advanced search'), t('Upload'), t('Download feature'), t('Report'), ), 'btn-success' => array( t('Add effect'), t('Add and configure'), t('Add'), t('Create'), t('Write'), t('Add more exceptions'), t('Add more additions'), ), 'btn-warning' => array( t('Export'), t('Import'), t('Restore'), t('Rebuild'), t('Apply'), t('Filter'), t('Change'), t('Go'), ), 'btn-info' => array( t('Preview'), t('Save and add'), t('Add another item'), t('Update style'), t('Apply'), t('Update'), t('Reset'), ), ); // String matching first. foreach ($button_strings as $class => $strings) { foreach ($strings as $string) { if (strpos(drupal_strtolower($value), drupal_strtolower($string)) !== FALSE) { return ' btn ' . $class; } } } return ' btn btn-default'; } function _zuitedesk_button_icontext($value) { // Text values containing these strings. $icon_strings = array( 'login' => array( t('Login'), t('Log in'), ), 'cog' => array( t('Manage'), t('Configure'), ), 'search' => array( t('Search'), t('Advanced search'), ), 'save' => array( t('Save'), ), 'trash' => array( t('Delete'), t('Remove'), t('Move to trash'), ), 'upload' => array( t('Submit'), t('Upload'), ), 'eye' => array( t('Preview'), ), 'download' => array( t('Download'), ), 'export' => array( t('Export'), ), 'import' => array( t('Import'), ), 'pencil' => array( t('Edit'), ), 'plus' => array( t('Add'), t('Write'), t('Add more exceptions'), t('Add more additions'), ), 'apply' => array( t('Apply'), t('Go'), ), 'reset' => array( t('Reset'), t('Update'), t('Change'), ), 'filter' => array( t('Filter'), ), 'page' => array( t('Report'), ), ); // String matching first. foreach ($icon_strings as $icon => $strings) { foreach ($strings as $string) { if (strpos(drupal_strtolower($value), drupal_strtolower($string)) !== FALSE) { return ' ' . $value; } } } return $value; } /** * Theming function for "Recently read" module. * * By default, Recently read block displays a list of links to node titles. This * function customize the output by overriding theme_recently_read_item(). */ function zuitedesk_recently_read_item($item) { global $base_url, $theme_path; $list_types = node_get_types(); $type = $item['type']; $type_name = t($list_types[$type]->name); $node_icon = $base_url . '/' . $theme_path . '/images/storm/' . substr($type, 5) . '.png'; $node_url = $base_url . '/' . drupal_get_path_alias('node/' . $item['nid']); $title = mb_strlen($item['title']) > 18 ? mb_substr($item['title'], 0, 18) .'…' : $item['title']; return '
    ' . '' . '' . $title . '
    '; }