Patch by Ax:
- Bad usage of css ID's: they may be used for a single element only, but were used as #node, #block, which can occur multiple times in a single page. - Moved HTML from theme to template - thats what templates are all about! - Added support for head() hook - Added support for diffentiating between boxes and blocks. - Typo: secundary -> secondary4.2.x
parent
bb9f9868eb
commit
cfd31c93f1
|
@ -69,6 +69,12 @@ class BaseTheme {
|
|||
print $output;
|
||||
}
|
||||
|
||||
function block($subject, $content, $region = "main") {
|
||||
global $theme;
|
||||
|
||||
$theme->box($subject, $content, $region);
|
||||
}
|
||||
|
||||
function footer() {
|
||||
$output = "</td></tr></table>";
|
||||
$output .= "</body></html>";
|
||||
|
@ -148,7 +154,13 @@ function theme_init() {
|
|||
return $obj;
|
||||
}
|
||||
|
||||
function theme_blocks($region, &$theme) {
|
||||
/**
|
||||
* Render blocks available for $user and $region calling $theme->block($region).
|
||||
*
|
||||
* @param string $region main|left|right
|
||||
* @param
|
||||
*/
|
||||
function theme_blocks($region) {
|
||||
global $user, $PHP_SELF;
|
||||
|
||||
$result = db_query("SELECT * FROM blocks WHERE (status = '1' OR custom = '1') ". ($region != "all" ? "AND region = '%s' " : "") ."ORDER BY weight, module", $region == "left" ? 0 : 1);
|
||||
|
@ -157,7 +169,7 @@ function theme_blocks($region, &$theme) {
|
|||
if ((($block->status && (!$user->uid || !$block->custom)) || ($block->custom && $user->block[$block->module][$block->delta])) && (!$block->path || preg_match("|$block->path|", $PHP_SELF))) {
|
||||
$block_data = module_invoke($block->module, "block", "view", $block->delta);
|
||||
if ($block_data["content"]) {
|
||||
$theme->box($block_data["subject"], $block_data["content"], $region);
|
||||
theme_invoke("block", $block_data["subject"], $block_data["content"], $region);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,30 +28,30 @@ p {
|
|||
img {
|
||||
border-width: 0;
|
||||
}
|
||||
table #menu {
|
||||
.header .menu {
|
||||
background-color: #69c;
|
||||
padding: 5px 5px 0px 5px;
|
||||
}
|
||||
#menu logo {
|
||||
.menu logo {
|
||||
vertical-align: bottom;
|
||||
float: left;
|
||||
}
|
||||
#menu #links {
|
||||
.menu #links {
|
||||
text-align: right;
|
||||
float: right;
|
||||
color: #9cf;
|
||||
}
|
||||
#menu #links #primary {
|
||||
.menu #links #primary {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
#menu #links #primary a {
|
||||
.menu #links #primary a {
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
}
|
||||
#menu #links #secundary {
|
||||
.menu #links #secondary {
|
||||
font-size: 0.7em;
|
||||
}
|
||||
#menu #links #secundary a {
|
||||
.menu #links #secondary a {
|
||||
color: #9cf;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
@ -67,61 +67,61 @@ table #menu {
|
|||
#sidebar {
|
||||
background-color: #ddd;
|
||||
}
|
||||
table #node {
|
||||
table .node {
|
||||
padding-bottom: 25px;
|
||||
}
|
||||
table #block {
|
||||
table .block, table .box {
|
||||
padding: 15px 15px 15px 15px;
|
||||
margin: 5px 0px 5px 0px;
|
||||
}
|
||||
table #comment {
|
||||
table .comment {
|
||||
border: 1px solid #bbb;
|
||||
padding: 15px 15px 15px 15px;
|
||||
margin: 5px 0px 5px 0px;
|
||||
}
|
||||
#node #title, #block #title, #node #title a {
|
||||
.node .title, .block .title, .box .title, .node .title a, .box .title a {
|
||||
padding-bottom: 5px;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
color: #888;
|
||||
}
|
||||
#node #author, #comment #author {
|
||||
.node .author, .comment .author {
|
||||
color: #999;
|
||||
font-size: 0.8em;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
#node #taxonomy {
|
||||
.node .taxonomy {
|
||||
color: #999;
|
||||
font-size: 0.8em;
|
||||
padding: 15px;
|
||||
}
|
||||
#node #taxonomy a {
|
||||
.node .taxonomy a {
|
||||
color: #369;
|
||||
}
|
||||
#node #content, #comment #content {
|
||||
.node .content, .comment .content {
|
||||
padding-top: 5px;
|
||||
}
|
||||
#node #links, #comment #links {
|
||||
.node .links, .comment .links {
|
||||
padding-top: 10px;
|
||||
color: #999;
|
||||
}
|
||||
#node #links a, #comment #links a {
|
||||
.node .links a, .comment .links a {
|
||||
font-weight: bold;
|
||||
color: #369;
|
||||
}
|
||||
#comment #title {
|
||||
.comment .title {
|
||||
font-weight: bold;
|
||||
font-size: 1.1em;
|
||||
color: #888;
|
||||
}
|
||||
#comment #new {
|
||||
.comment .new {
|
||||
text-align: right;
|
||||
font-weight: bold;
|
||||
font-size: 0.7em;
|
||||
float: right;
|
||||
color: red;
|
||||
}
|
||||
#block #content {
|
||||
.block .content, .box .content {
|
||||
font-size: 0.9em/1.1em;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?
|
||||
<?php
|
||||
|
||||
class XTemplate {
|
||||
|
||||
|
@ -477,6 +477,23 @@ function r_getfile($file) {
|
|||
|
||||
/*
|
||||
$Log$
|
||||
Revision 1.2 2003/02/01 19:54:19 dries
|
||||
|
||||
Patch by Ax:
|
||||
|
||||
- Bad usage of css ID's: they may be used for a single element only,
|
||||
but were used as #node, #block, which can occur multiple times in a
|
||||
single page.
|
||||
|
||||
- Moved HTML from theme to template - thats what templates are all
|
||||
about!
|
||||
|
||||
- Added support for head() hook
|
||||
|
||||
- Added support for diffentiating between boxes and blocks.
|
||||
|
||||
- Typo: secundary -> secondary
|
||||
|
||||
Revision 1.1 2003/01/20 21:00:31 dries
|
||||
|
||||
- Added a template driven theme.
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
class Theme_xtemplate extends BaseTheme {
|
||||
|
||||
var $primary_links = "edit me";
|
||||
var $secundary_links = "edit me";
|
||||
var $secondary_links = "edit me";
|
||||
var $message = "edit me";
|
||||
|
||||
function system($field) {
|
||||
$system["name"] = "xtemplate";
|
||||
$system["description"] = "a template driven theme";
|
||||
|
||||
return $system[$field];
|
||||
}
|
||||
|
@ -36,13 +37,13 @@ class Theme_xtemplate extends BaseTheme {
|
|||
check_output($node->teaser) :
|
||||
check_output($node->body)));
|
||||
|
||||
if ($links = link_node($node, $main)) {
|
||||
$this->template->assign("links", $this->links($links));
|
||||
}
|
||||
if ($links = link_node($node, $main)) {
|
||||
$this->template->assign("links", $this->links($links));
|
||||
}
|
||||
|
||||
$this->template->parse("node");
|
||||
print $this->template->text("node");
|
||||
$this->template->reset("node");
|
||||
$this->template->parse("node");
|
||||
print $this->template->text("node");
|
||||
$this->template->reset("node");
|
||||
}
|
||||
|
||||
function comment($comment, $link = 0) {
|
||||
|
@ -65,73 +66,53 @@ class Theme_xtemplate extends BaseTheme {
|
|||
}
|
||||
}
|
||||
|
||||
function header() {
|
||||
function header($title = "") {
|
||||
$this->template->assign(array(
|
||||
"name" => variable_get("site_name", ""),
|
||||
"slogan" => variable_get("site_slogan", "")));
|
||||
"title" => ($title ? $title." | ". variable_get("site_name", "drupal") : variable_get("site_name", "drupal") ." | ". variable_get("site_slogan", "")),
|
||||
"head" => theme_head(),
|
||||
"primary" => $this->primary_links,
|
||||
"secondary" => $this->secondary_links
|
||||
));
|
||||
|
||||
if (!arg(0)) {
|
||||
$this->template->assign("message", $this->message);
|
||||
$this->template->parse("header.message");
|
||||
}
|
||||
|
||||
$this->template->parse("header");
|
||||
print $this->template->text("header");
|
||||
}
|
||||
|
||||
?>
|
||||
<table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td colspan="2" id="menu">
|
||||
<?php
|
||||
|
||||
function block($title, $content, $region = "main") {
|
||||
$this->template->assign(array(
|
||||
"primary" => $this->primary_links,
|
||||
"secundary" => $this->secundary_links));
|
||||
"subject" => $title,
|
||||
"content" => $content
|
||||
));
|
||||
|
||||
$this->template->parse("menu");
|
||||
print $this->template->text("menu");
|
||||
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" width="100%">
|
||||
<?php
|
||||
|
||||
// the description block is only shown on the main page
|
||||
if (!arg(0)) {
|
||||
$this->template->assign(array(
|
||||
"message" => $this->message));
|
||||
|
||||
$this->template->parse("message");
|
||||
print $this->template->text("message");
|
||||
}
|
||||
|
||||
?>
|
||||
<div id="main">
|
||||
<?php
|
||||
$this->template->parse("block");
|
||||
print $this->template->text("block");
|
||||
$this->template->reset("block");
|
||||
}
|
||||
|
||||
function box($title, $content, $region = "main") {
|
||||
if ($title && $content) {
|
||||
$this->template->assign(array(
|
||||
"title" => $title,
|
||||
"subject" => $title,
|
||||
"content" => $content));
|
||||
|
||||
$this->template->parse("block");
|
||||
print $this->template->text("block");
|
||||
$this->template->reset("block");
|
||||
$this->template->parse("box");
|
||||
print $this->template->text("box");
|
||||
$this->template->reset("box");
|
||||
}
|
||||
}
|
||||
|
||||
function footer() {
|
||||
global $user;
|
||||
|
||||
?>
|
||||
<td valign="top" rowspan="2" id="sidebar">
|
||||
<?php
|
||||
theme_blocks("all", $this);
|
||||
?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
// unfortunately, theme_blocks PRINTS the blocks instead of RETURNING them.
|
||||
// so we need some output buffering
|
||||
ob_start();
|
||||
theme_blocks("all");
|
||||
$this->template->assign("blocks", ob_get_contents());
|
||||
ob_end_clean();
|
||||
|
||||
$this->template->parse("footer");
|
||||
print $this->template->text("footer");
|
||||
|
|
|
@ -2,68 +2,93 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<title>{name} - {slogan}</title>
|
||||
<style type="text/css" media="all">
|
||||
@import "themes/xtemplate/xtemplate.css";
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<head>
|
||||
<title>{title}</title>
|
||||
<style type="text/css" media="all">
|
||||
@import "themes/xtemplate/xtemplate.css";
|
||||
</style>
|
||||
{head}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" class="header">
|
||||
|
||||
<tr>
|
||||
<td colspan="2" class="menu">
|
||||
<span id="links">
|
||||
<div id="secondary">{secondary}</div>
|
||||
<div id="primary">{primary}</div>
|
||||
</span>
|
||||
<span id="logo"><a href="index.php"><img src="themes/xtemplate/images/druplicon.gif" alt="" /></a></span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td valign="top" width="100%">
|
||||
<!-- BEGIN: message -->
|
||||
<div id="message">{message}</div>
|
||||
<!-- END: message -->
|
||||
<div id="main">
|
||||
<!-- END: header -->
|
||||
|
||||
<!-- BEGIN: menu -->
|
||||
<span id="links">
|
||||
<div id="secundary">{secundary}</div>
|
||||
<div id="primary">{primary}</div>
|
||||
</span>
|
||||
<span id="logo"><a href="index.php"><img src="themes/xtemplate/images/druplicon.gif" alt="" /></a></span>
|
||||
<!-- END: menu -->
|
||||
|
||||
|
||||
<!-- BEGIN: message -->
|
||||
<div id="message">{message}</div>
|
||||
<!-- END: message -->
|
||||
|
||||
|
||||
<!-- BEGIN: node -->
|
||||
<div id="node">
|
||||
<div id="title">{title}</div>
|
||||
<span id="author">Submitted by {author} on {date}.</span>
|
||||
<span id="taxonomy">{taxonomy}</span>
|
||||
<div id="content">{content}</div>
|
||||
<div id="links">» {links}</div>
|
||||
<div class="node">
|
||||
<div class="title">{title}</div>
|
||||
<span class="author">Submitted by {author} on {date}.</span>
|
||||
<span class="taxonomy">{taxonomy}</span>
|
||||
<div class="content">{content}</div>
|
||||
<div class="links">» {links}</div>
|
||||
</div>
|
||||
<!-- END: node -->
|
||||
|
||||
<!-- BEGIN: comment_new -->
|
||||
<div id="comment">
|
||||
<span id="new">new</span>
|
||||
<div id="title">{title}</div>
|
||||
<div id="author">Posted by {author} on {date}.</div>
|
||||
<div id="content">{content}</div>
|
||||
<div id="links">» {links}</div>
|
||||
</div>
|
||||
<div class="comment">
|
||||
<span class="new">new</span>
|
||||
<div class="title">{title}</div>
|
||||
<div class="author">Posted by {author} on {date}.</div>
|
||||
<div class="content">{content}</div>
|
||||
<div class="links">» {links}</div>
|
||||
</div>
|
||||
<!-- END: comment_new -->
|
||||
|
||||
<!-- BEGIN: comment_old -->
|
||||
<div id="comment">
|
||||
<div id="title">{title}</div>
|
||||
<div id="author">Posted by {author} on {date}.</div>
|
||||
<div id="content">{content}</div>
|
||||
<div id="links">» {links}</div>
|
||||
</div>
|
||||
<div class="comment">
|
||||
<div class="title">{title}</div>
|
||||
<div class="author">Posted by {author} on {date}.</div>
|
||||
<div class="content">{content}</div>
|
||||
<div class="links">» {links}</div>
|
||||
</div>
|
||||
<!-- END: comment_old -->
|
||||
|
||||
|
||||
<!-- BEGIN: box -->
|
||||
<div class="box">
|
||||
<div class="title">{subject}</div>
|
||||
<div class="content">{content}</div>
|
||||
</div>
|
||||
<!-- END: box -->
|
||||
|
||||
|
||||
<!-- BEGIN: block -->
|
||||
<div id="block">
|
||||
<div id="title">{title}</div>
|
||||
<div id="content">{content}</div>
|
||||
<div class="block">
|
||||
<div class="title">{subject}</div>
|
||||
<div class="content">{content}</div>
|
||||
</div>
|
||||
<!-- END: block -->
|
||||
|
||||
|
||||
<!-- BEGIN: footer -->
|
||||
</body>
|
||||
</div><!-- main -->
|
||||
</td>
|
||||
<td valign="top" id="sidebar">
|
||||
{blocks}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<!-- END: footer -->
|
||||
|
|
Loading…
Reference in New Issue