theme.inc 3.93 KB
Newer Older
Dries's avatar
 
Dries committed
1
<?php
2

Kjartan's avatar
Changes  
Kjartan committed
3
class BaseTheme {
Dries's avatar
 
Dries committed
4 5
  function links($links, $delimiter = " | ") {
    return implode($delimiter, $links);
Dries's avatar
 
Dries committed
6
  }
Kjartan's avatar
Changes  
Kjartan committed
7 8
}

Dries's avatar
 
Dries committed
9
function theme_init() {
Dries's avatar
 
Dries committed
10 11 12
  global $user, $themes;

  if ($user->theme && file_exists($themes[$user->theme][0])) {
Dries's avatar
 
Dries committed
13
    include_once $themes[$user->theme][0];
Dries's avatar
 
Dries committed
14 15
  }
  else {
Dries's avatar
 
Dries committed
16
    include_once $themes[variable_get("theme_default", key($themes))][0];
Dries's avatar
 
Dries committed
17 18 19 20
  }
  return new Theme();
}

Dries's avatar
 
Dries committed
21
function theme_account($theme) {
Dries's avatar
 
Dries committed
22
  global $user;
Dries's avatar
 
Dries committed
23 24

  if ($user->id) {
Dries's avatar
 
Dries committed
25
    // Display account settings:
Dries's avatar
 
Dries committed
26 27 28
    $content .= "<A HREF=\"account.php?op=track&topic=comments\">". t("track your comments") ."</A><BR>\n";
    $content .= "<A HREF=\"account.php?op=track&topic=nodes\">". t("track your nodes") ."</A><BR>\n";
    $content .= "<A HREF=\"account.php?op=track&topic=site\">". strtr(t("track %a"), array("%a" => variable_get("site_name", "drupal"))) ."</A><BR>\n";
Dries's avatar
 
Dries committed
29
    $content .= "<P>\n";
Dries's avatar
 
Dries committed
30 31 32
    $content .= "<A HREF=\"account.php?op=edit&topic=user\">". t("edit your information") ."</A><BR>\n";
    $content .= "<A HREF=\"account.php?op=edit&topic=site\">". t("edit your preferences") ."</A><BR>\n";
    $content .= "<A HREF=\"account.php?op=edit&topic=content\">". t("edit your content") ."</A><BR>\n";
Dries's avatar
 
Dries committed
33
    $content .= "<P>\n";
Dries's avatar
 
Dries committed
34

Dries's avatar
 
Dries committed
35
    if (user_access("access administration pages")) {
Dries's avatar
 
Dries committed
36
      $content .= "<A HREF=\"admin.php\">". strtr(t("administer %a"), array("%a" => variable_get("site_name", "drupal"))) ."</A><BR>\n";
Dries's avatar
 
Dries committed
37
      $content .= "<P>\n";
Dries's avatar
 
Dries committed
38 39
    }

Dries's avatar
 
Dries committed
40
    foreach (module_list() as $name) {
Dries's avatar
 
Dries committed
41 42
      if (module_hook($name, "link")) {
        $links = module_invoke($name, "link", "menu");
Dries's avatar
 
Dries committed
43
        foreach ($links as $link) $content .= "$link<BR>\n";
Dries's avatar
 
Dries committed
44
      }
Dries's avatar
 
Dries committed
45
    }
Dries's avatar
 
Dries committed
46
    if ($link) $content .= "<P>\n";
Dries's avatar
 
Dries committed
47

Dries's avatar
 
Dries committed
48
    $content .= "<A HREF=\"account.php?op=logout\">". t("logout") ."</A><BR>\n";
Dries's avatar
 
Dries committed
49

Dries's avatar
 
Dries committed
50
    $theme->box(strtr(t("%a's configuration"), array("%a" => $user->userid)), "$content");
Dries's avatar
 
Dries committed
51 52
  }
  else {
Dries's avatar
 
Dries committed
53
    $output .= "<DIV ALIGN=\"center\">\n";
Dries's avatar
 
Dries committed
54 55 56 57
    $output .= " <FORM ACTION=\"account.php?op=login\" METHOD=\"post\">\n";
    $output .= "  <B>". t("Username") .":</B><BR><INPUT NAME=\"userid\" SIZE=\"15\"><P>\n";
    $output .= "  <B>". t("Password") .":</B><BR><INPUT NAME=\"passwd\" SIZE=\"15\" TYPE=\"password\"><BR>\n";
    $output .= "  <INPUT TYPE=\"submit\" VALUE=\"". t("Login") ."\"><BR>\n";
Dries's avatar
 
Dries committed
58
    if (variable_get("account_register", 1)) $output .= "  <A HREF=\"account.php\">". t("REGISTER") ."</A>\n";
Dries's avatar
 
Dries committed
59
    $output .= " </FORM>\n";
Dries's avatar
 
Dries committed
60
    $output .= "</DIV>\n";
Dries's avatar
 
Dries committed
61

Dries's avatar
 
Dries committed
62
    $theme->box(t("Login"), $output);
Dries's avatar
 
Dries committed
63 64 65 66
  }
}


Dries's avatar
 
Dries committed
67
function theme_blocks($region, $theme) {
Dries's avatar
 
Dries committed
68
  global $id, $PHP_SELF, $status, $user;
Dries's avatar
 
Dries committed
69

Dries's avatar
 
Dries committed
70
  switch (strrchr($PHP_SELF, "/")) {
Dries's avatar
 
Dries committed
71
    case "/node.php":
Dries's avatar
 
Dries committed
72
      if ($region != "left") {
Dries's avatar
 
Dries committed
73
        if ($user->id) $node = db_fetch_object(db_query("SELECT * FROM node WHERE nid = '$id'"));
Dries's avatar
 
Dries committed
74
        if ($node->status == $status[queued]) theme_moderation_results($theme, $node);
Dries's avatar
 
Dries committed
75
        // else theme_new_headlines($theme);
Dries's avatar
 
Dries committed
76
      }
Dries's avatar
 
Dries committed
77
      break;
Dries's avatar
 
Dries committed
78
    case "/index.php":
Dries's avatar
Dries committed
79
      if ($user->id) $result = db_query("SELECT * FROM blocks b LEFT JOIN layout l ON b.name = l.block WHERE (b.status = 2 OR (b.status = 1 AND l.user = '$user->id'))". (($region == "left" || $region == "right") ? ($region == "left" ? " AND b.region = 0" : " AND b.region = 1") : "") ." ORDER BY weight");
Dries's avatar
 
Dries committed
80
      else $result = db_query("SELECT * FROM blocks WHERE status = 2". (($region == "left" || $region == "right") ? ($region == "left" ? " AND region = 0" : " AND region = 1") : "") ." ORDER BY weight");
Dries's avatar
 
Dries committed
81
      while ($block = db_fetch_object($result)) {
Dries's avatar
 
Dries committed
82
        $blocks = module_invoke($block->module, "block");
Dries's avatar
 
Dries committed
83
        $theme->box(t($blocks[$block->offset]["subject"]), $blocks[$block->offset]["content"]);
Dries's avatar
 
Dries committed
84 85
      }
      break;
Dries's avatar
 
Dries committed
86 87 88
  }
}

Dries's avatar
 
Dries committed
89
function theme_moderation_results($theme, $node) {
90
  foreach (explode(",", $node->users) as $vote) {
Dries's avatar
 
Dries committed
91
    if ($vote) {
92
      $data = explode("=", $vote);
Dries's avatar
 
Dries committed
93
      $output .= format_username($data[0]) ." voted '$data[1]'.<BR>";
Dries's avatar
 
Dries committed
94 95
    }
  }
Dries's avatar
 
Dries committed
96 97

  $theme->box(t("Moderation results"), ($output ? $output : t("This node has not been moderated yet.")));
Dries's avatar
 
Dries committed
98 99
}

Dries's avatar
 
Dries committed
100
?>