function studentparlamentet_preprocess_page(&$vars, $hook) { // Currently logged in user global $user; if (arg(0) == 'user') { $vars['title'] = t('Login'); } //if(function_exists('spaces_get_space')){ $space = spaces_get_space(); if ($space) { // If we are in space, prepare and send space related variables to template $vars['spacetype'] = $space->type; $vars['spacetitle'] = l($space->group->title, '<front>'); } $banner = _make_banner_links($space); if ($banner) { $vars['space_settings_flyout'] = $banner; } // For easy printing of variables. $vars['logo_img'] = $vars['logo'] ? theme('image', substr($vars['logo'], strlen(base_path())), t('Home'), t('Home')) : ''; $vars['linked_logo_img'] = $vars['logo_img'] ? l($vars['logo_img'], '<front>', array('rel' => 'home', 'title' => t('Home'), 'html' => TRUE)) : ''; //$vars['linked_site_name'] = $vars['site_name'] ? l($vars['site_name'], '<front>', array('rel' => 'home', 'title' => t('Home'))) : ''; $vars['main_menu_links'] = theme('links', $vars['primary_links'], array('class' => 'links main-menu')); $vars['secondary_menu_links'] = theme('links', $vars['secondary_links'], array('class' => 'links secondary-menu')); // Make sure framework styles are placed above all others. #$vars['css_alt'] = zen_ninesixty_css_reorder($vars['css']); #$vars['styles'] = drupal_get_css($vars['css_alt']); // This line of code was borrowed from conditional_style module (http://drupal.org/project/conditional_styles) $vars['styles'] .= $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'], ''); // Classes for body element. Allows advanced theming based on context // (home page, node of certain type, etc.) $classes = split(' ', $vars['body_classes']); $vars['body_classes_array'] = $classes; $vars['body_classes'] = implode(' ', $classes); // Concatenate with spaces. // vjo: får designkit til å virke i zen_ninesixty: http://drupal.org/node/814548#comment-3174320 // note: hele designkit_preprocess_page fra designkit.module er kopiert inn for å få dette til å // funke, men noe trengs kanskje ikke.. (?) /* $info = designkit_get_info(); $color = !empty($info['designkit']['color']) ? variable_get('designkit_color', array()) : array(); $image = !empty($info['designkit']['image']) ? variable_get('designkit_image', array()) : array(); */ // Clear out stale values for image keys. This prevents themes from // getting unexpected values if no images have been set. if (!empty($info['designkit']['image'])) { foreach (array_keys($info['designkit']['image']) as $name) { if (isset($vars[$name])) { unset($vars[$name]); } } } }
protected function checkEntityAccess($op, $entity_type, $entity) { $request = $this->getRequest(); if ($request['vsite']) { spaces_set_space(spaces_load('og', $request['vsite'])); } if (empty($entity->nid)) { // This is still a new node. Skip. return; } if ($is_group = og_is_group($entity_type, $entity)) { $group = $entity; } else { $wrapper = entity_metadata_wrapper('node', $entity); $group = $wrapper->{OG_AUDIENCE_FIELD}->get(0)->value(); } if (empty($request['vsite'])) { spaces_set_space(spaces_load('og', $group->nid)); } $manager = og_user_access('node', $group->nid, 'administer users', $this->getAccount()); if ($is_group) { // In addition to the node access check, we need to see if the user can // manage groups. return $manager && !vsite_access_node_access($group, 'view', $this->getAccount()) == NODE_ACCESS_DENY; } else { $app = os_get_app_by_bundle($entity->type); $space = spaces_get_space(); $application_settings = $space->controllers->variable->get('spaces_features'); switch ($application_settings[$app]) { case OS_DISABLED_APP: return FALSE; case OS_PRIVATE_APP: return og_is_member('node', $group->nid, 'user', $this->getAccount()) && parent::checkEntityAccess($op, $entity_type, $entity); default: case OS_PUBLIC_APP: return parent::checkEntityAccess($op, $entity_type, $entity); } } }
/** * Override of theme_breadcrumb(). */ function ginkgo_breadcrumb($breadcrumb) { $breadcrumb = empty($breadcrumb) ? array(l(t('Home'), '<front>')) : $breadcrumb; $i = 0; foreach ($breadcrumb as $k => $link) { $breadcrumb[$k] = "<span class='link link-{$i}'>{$link}</span>"; $i++; } $breadcrumb = implode("<span class='divider'></span>", $breadcrumb); // Marker for this group as public or private. $space = spaces_get_space(); if ($space && $space->type === 'og') { $attr = $space->group->og_private ? array('title' => t('Private'), 'class' => 'private') : array('title' => t('Public'), 'class' => 'public'); $link = l('', $_GET['q'], array('attributes' => $attr)); $breadcrumb .= "<span class='space'>{$link}</span>"; } return "<div class='breadcrumb'>{$breadcrumb}</div>"; }
/** * Make logo markup overridable. */ function ginkgo_spaces_design_logo($filepath) { $url = imagecache_create_url('spaces-logo', $filepath); $space = spaces_get_space(); $options = array('attributes' => array('class' => 'spaces-logo', 'style' => 'background-image:url(\'' . $url . '\')')); return l($space->title, '<front>', $options); }
/** * Preprocessor for page.tpl.php template file. */ function dewey_preprocess_page(&$vars, $hook) { global $user; $space = spaces_get_space(); $context = context_get(); $vars['space'] = $space; $vars['context'] = $context; // Replace screen/all stylesheets with print // We want a minimal print representation here for full control. if (isset($_GET['print'])) { $css = drupal_add_css(); unset($css['all']); unset($css['screen']); $css['all'] = $css['print']; $vars['styles'] = drupal_get_css($css); // Add print header $vars['print_header'] = theme('print_header'); // Replace all body classes $attr['class'] = 'print'; // Use print template $vars['template_file'] = 'print-page'; // Suppress devel output $GLOBALS['devel_shutdown'] = FALSE; } // If user is not a member of the group, add an "Join group" button. if (!empty($space) && $space->controllers->variable->space_type == "og" && !in_array($space->id, array_keys($user->og_groups))) { $add_group = array('add-group' => array('title' => t('Join group'), 'href' => 'og/subscribe/' . $space->id)); $vars['context_links'] = theme('links', $add_group); } // If we're on on a user page or a group page, add an add group link. if (empty($vars['context_links']) && !in_array($space->controllers->variable->space_type, array('og', 'user')) && $user->uid != 0) { $add_group = array('add-group' => array('title' => t('Add Group'), 'href' => 'node/add/group')); $vars['context_links'] = theme('links', $add_group); } // If we're in the discussion context, add an add discussion link. if (empty($vars['context_links']) && isset($context['context']['spaces-feature-discussion'])) { $add_discussion = array('add-discussion' => array('title' => t('Add Discussion'), 'href' => 'node/add/story')); $vars['context_links'] = theme('links', $add_discussion); } // Path to theme $vars['path'] = base_path() . path_to_theme() . '/'; // Create login or account page. list($user_picture, $user_picture_preset) = dewey_comment_user_picture($user->picture, $user->uid); $user_picture = "<div class='picture grid-1'>" . $user_picture . "</div>"; $vars['user_picture'] = $user_picture; if ($user->uid) { $vars['user_account'] = $user_picture . " " . l($user->name, 'user') . " " . l('logout', 'logout'); } else { $vars['user_account'] = l('Login', 'user', array('attributes' => array('class' => 'user-account'))); } $vars['user_account'] = "<span class='user-links'>" . $vars['user_account'] . "</span>"; // Set title if ($space) { if (!empty($space->group->title)) { $vars['space_title'] = l(strtoupper($space->group->title), '<front>'); } } else { $vars['space_title'] = $vars['title']; } // Create the menu item for the group settings tab for group admins. if (!empty($space) && $space->type == 'og') { $result = db_result(db_query("SELECT uid\n FROM {og_uid}\n WHERE is_admin = 1\n AND nid = %d\n AND uid = %d", $space->id, $user->uid)); if ($result || $user->uid == 1) { $vars['space_settings'] = theme('group_settings_dropdown', $space); } } // Add custom breadcrumb. $active_menu = ""; if (!empty($context['context'])) { $contexts = array_keys($context['context']); foreach ($contexts as $item) { if (preg_match('/spaces-feature.*/', $item, $matches)) { $active_menu = $context['context'][$item]->reactions['menu']; } } } $breadcrumb .= "<div id='breadcrumb'"; $breadcrumb .= l("Home", base_path(), array('external' => true)) . " > "; if (isset($space->id)) { $breadcrumb .= l($space->group->title, ""); if (!empty($active_menu)) { $breadcrumb .= " > " . l(capitalizeWords($active_menu), $active_menu); } } else { $breadcrumb = trim($breadcrumb, " >"); } $breadcrumb .= "</div>"; $vars['breadcrumb'] = $breadcrumb; $vars['meta'] = ''; // SEO optimization, add in the node's teaser, or if on the homepage, the mission statement // as a description of the page that appears in search engines if ($vars['is_front'] && $vars['mission'] != '') { $vars['meta'] .= '<meta name="description" content="' . dewey_trim_text($vars['mission']) . '" />' . "\n"; } else { if (isset($vars['node']->teaser) && $vars['node']->teaser != '') { $vars['meta'] .= '<meta name="description" content="' . dewey_trim_text($vars['node']->teaser) . '" />' . "\n"; } else { if (isset($vars['node']->body) && $vars['node']->body != '') { $vars['meta'] .= '<meta name="description" content="' . dewey_trim_text($vars['node']->body) . '" />' . "\n"; } } } // SEO optimization, if the node has tags, use these as keywords for the page if (isset($vars['node']->taxonomy)) { $keywords = array(); foreach ($vars['node']->taxonomy as $term) { $keywords[] = $term->name; } $vars['meta'] .= '<meta name="keywords" content="' . implode(',', $keywords) . '" />' . "\n"; } // SEO optimization, avoid duplicate titles in search indexes for pager pages if (isset($_GET['page']) || isset($_GET['sort'])) { $vars['meta'] .= '<meta name="robots" content="noindex,follow" />' . "\n"; } }
function template_preprocess_filedepot_filedetail(&$variables) { $filedepot = filedepot_filedepot(); $nexcloud = filedepot_nexcloud(); $fid = $variables['fid']; $variables['site_url'] = base_path(); $variables['ajax_server_url'] = url('filedepot_ajax'); $variables['LANG_download'] = t('Download File'); $variables['LANG_lastupated'] = t('Last Updated'); $variables['show_statusmsg'] = 'none'; $limit = FALSE; if ($variables['reportmode'] == 'approvals') { $sql = "SELECT file.cid,file.title,file.fname,file.date,file.version,file.size, "; $sql .= "file.description,file.submitter,file.status,file.version_note as notes,tags "; $sql .= "FROM {filedepot_filesubmissions} file "; $sql .= "WHERE file.id=:fid"; } elseif ($variables['reportmode'] == 'incoming') { $sql = "SELECT 0,file.orig_filename as title,file.orig_filename as fname,file.timestamp,1,file.size, "; $sql .= "file.description,file.uid,9,file.version_note,'' "; $sql .= "FROM {filedepot_import_queue} file "; $sql .= "WHERE file.id=:fid"; } else { $sql = "SELECT file.cid, file.title, v.fname, file.date, file.version, file.size, "; $sql .= "file.description, file.submitter, file.status, v.notes, '' as tags "; $sql .= "FROM {filedepot_files} file "; $sql .= "LEFT JOIN {filedepot_fileversions} v ON v.fid=file.fid "; $sql .= "WHERE file.fid=:fid ORDER BY v.version DESC "; $limit = 1; } $filedetail = FALSE; if ($limit !== FALSE) { $query = db_query_range($sql, 0, 1, array(':fid' => $fid)); } else { $query = db_query($sql, array(':fid' => $fid)); } $A = $query->fetchAssoc(); if ($A != NULL) { list($cid, $title, $fname, $date, $cur_version, $size, $description, $submitter, $status, $cur_notes, $tags) = array_values($A); $variables['cid'] = $cid; $variables['shortdate'] = strftime($filedepot->shortdate, $date); $variables['size'] = filedepot_formatFileSize($size); $icon = $filedepot->getFileIcon($fname); $variables['fileicon'] = "{$variables['layout_url']}/css/images/{$icon}"; $author = db_query("SELECT name FROM {users} WHERE uid=:uid", array(':uid' => $submitter))->fetchField(); $catname = db_query("SELECT name FROM {filedepot_categories} WHERE cid=:cid", array(':cid' => $cid))->fetchField(); $nid = db_query("SELECT nid FROM {filedepot_categories} WHERE cid=:cid", array(':cid' => $cid))->fetchField(); $variables['fname'] = filter_xss($fname); $variables['current_version'] = "(V{$cur_version})"; $variables['filetitle'] = filter_xss($title); $variables['real_filename'] = filter_xss($fname); $variables['author'] = $author; $variables['description'] = nl2br(filter_xss($description)); $variables['foldername'] = filter_xss($catname); $variables['current_ver_note'] = nl2br(filter_xss($cur_notes)); $variables['tags'] = $nexcloud->get_itemtags($fid); $variables['disable_download'] = ''; if ($status == FILEDEPOT_UNAPPROVED_STATUS) { $variables['show_statusmsg'] = ''; $variables['status_image'] = '<img src="' . $variables['layout_url'] . '/css/images/padlock.gif">'; $variables['statusmessage'] = '* ' . t('File Submission to Approve'); } elseif ($status == FILEDEPOT_INCOMING_STATUS) { $variables['show_statusmsg'] = ''; $variables['status_image'] = ' '; $variables['statusmessage'] = '* ' . t('Incoming File - needs to be moved or deleted'); $variables['disable_download'] = 'onClick="return false;"'; } elseif ($status == FILEDEPOT_LOCKED_STATUS) { $variables['show_statusmsg'] = ''; $stat_userid = db_query("SELECT status_changedby_uid FROM {filedepot_files} WHERE fid=:fid", array(':fid' => $fid))->fetchField(); $stat_user = db_query("SELECT name FROM {users} WHERE uid=:uid", array(':uid' => $stat_userid))->fetchField(); $variables['status_image'] = '<img src="' . $variables['layout_url'] . '/css/images/padlock.gif">'; $variables['statusmessage'] = '* ' . t('Locked by %name', array('%name' => $stat_user)); $variables['LANG_DOWNLOAD_MESSAGE'] = t('File Locked by: %name', array('%name' => $stat_user)); $variables['disable_download'] = 'onClick="return FALSE;"'; } else { $variables['status_image'] = ' '; $variables['statusmessage'] = ' '; } if (function_exists('spaces_get_space')) { $space = spaces_get_space(); if ($space && $space->type === 'og') { $urlprefix = ''; switch (variable_get('purl_method_spaces_og', 'path')) { case 'path': $urlprefix = "{$space->group->purl}"; break; case 'pair': $urlprefix = "{$key}/{$space->id}"; break; } } } $clean_urls_on = variable_get('clean_url', 0); if ($clean_urls_on == 1) { $url_separator = "/"; } else { $url_separator = "?q="; } if (isset($urlprefix) and !empty($urlprefix)) { $variables['download_url'] = base_path() . "index.php{$url_separator}{$urlprefix}/filedepot&cid={$cid}&fid={$fid}"; } else { $variables['download_url'] = base_path() . "index.php{$url_separator}filedepot&cid={$cid}&fid={$fid}"; } // Retrieve file versions $sql = "SELECT fid,fname,version,notes,size,date,uid FROM {filedepot_fileversions} " . "WHERE fid=:fid AND version < :version ORDER by version DESC"; $query = db_query($sql, array(':fid' => $fid, ':version' => $cur_version)); $version_records = ''; if ($query) { while ($rec = $query->fetchAssoc()) { $rec['nid'] = $nid; $version_records .= theme('filedepot_fileversion', array('versionRec' => $rec)); } } $variables['version_records'] = $version_records; } }