コード例 #1
0
ファイル: node.tpl.php プロジェクト: KyleAMathews/dewey
if ($submitted) {
    ?>
      <div class="node-submitted clear-block"><?php 
    print $submitted;
    ?>
</div>
    <?php 
}
?>
    <div class="content clear-block">
      <?php 
if (!$page) {
    ?>
        <div class="trimmed-content">
          <?php 
    print dewey_trim_text($content, 160);
    ?>
          <a href="#" class="expand-post">(more)</a>
        </div>
      <?php 
}
?>
      <div class="full-content">
        <?php 
print $content;
?>
      </div>
    </div>
  </div>
  
</div>
コード例 #2
0
ファイル: template.php プロジェクト: KyleAMathews/dewey
/**
 * 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";
    }
}
print $fields['picture']->content;
?>
  </div>

  <div class='grid-10 activity-title omega'>
    <h3>
      <?php 
print "<span class='activity-item-group-name'>[" . l($group_name, $purl) . "]</span> ";
print "<span class='activity-node-title'>" . $fields['title']->content . "</span>";
?>
    </h3>
  </div>
  
  <div class='grid-10 activity-teaser omega'>
    <?php 
print dewey_trim_text($fields['body']->content, 200);
?>
    <a href="#" class="activity-teaser-expand">Expand this post &raquo;</a>
  </div>
  
  <div class='grid-10 activity-body omega'>
    <?php 
print check_markup($fields['body']->raw);
?>
  </div>

  <div class="grid-8 activity-meta">
    <?php 
print $fields['created']->content;
?>
 by <?php