Skip to content
Commits on Source (94)
Drupal x.x.x, xxxx-xx-xx
Drupal 4.4.2, 2004-07-04
------------------------
- fixed bugs: no critical bugs were identified.
Drupal 4.4.1, 2004-05-01
------------------------
- fixed bugs: no critical bugs were identified.
Drupal 4.4.0, 2004-04-01
------------------------
- added support for the MetaWeblog API and MovableType extensions.
......
......@@ -32,10 +32,6 @@ LOCALE MODULE
M: Gabor Hojtsy <goba@php.net>
S: maintained
MSSQL PORT
M: Moshe Weitzman <weitzman@tejasa.com>
S: maintained
POSTGRES PORT
M: Adrian Rossouw <adrian@obsidian.co.za>
S: maintained
......@@ -49,8 +45,8 @@ M: Moshe Weitzman <weitzman@tejasa.com>
S: maintained
DEBIAN PACKAGE
M: Hugo Espuny <hec@debian.org>
S: orphan
M: Hilko Bengen <bengen@debian.org>
S: maintained
THE REST:
M: Dries <dries@drupal.org>
---
--- Table definitions
---
CREATE TABLE [dbo].[access] (
[aid] [smallint] NULL ,
[mask] [varchar] (255) NOT NULL ,
[type] [varchar] (255) NOT NULL ,
[status] [smallint] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[accesslog] (
[nid] [numeric](11, 0) NULL ,
[url] [varchar] (255) NULL ,
[hostname] [varchar] (128) NULL ,
[uid] [numeric](10, 0) NULL ,
[timestamp] [numeric](11, 0) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[authmap] (
[aid] [numeric](10, 0) IDENTITY NULL ,
[uid] [int] NOT NULL ,
[authname] [varchar] (128) NOT NULL ,
[module] [varchar] (128) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[blocks] (
[module] [varchar] (64) NOT NULL ,
[delta] [varchar] (32) NOT NULL ,
[status] [smallint] NOT NULL ,
[weight] [smallint] NOT NULL ,
[region] [smallint] NOT NULL ,
[path] [varchar] (255) NOT NULL ,
[custom] [smallint] NOT NULL,
[throttle] [smallint] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[book] (
[nid] [numeric](4, 0) NOT NULL ,
[parent] [int] NOT NULL ,
[weight] [smallint] NOT NULL ,
[format] [smallint] NULL ,
[log] [text] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[boxes] (
[bid] [smallint] NULL ,
[title] [varchar] (64) NOT NULL ,
[body] [text] NULL ,
[info] [varchar] (128) NOT NULL ,
[type] [smallint] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[bundle] (
[bid] [int] NULL ,
[title] [varchar] (255) NOT NULL ,
[attributes] [varchar] (255) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[cache] (
[cid] [varchar] (255) NOT NULL ,
[data] [text] NULL ,
[expire] [int] NOT NULL ,
[created] [int] NOT NULL ,
[headers] [text] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[comments] (
[cid] [int] NULL ,
[pid] [int] NOT NULL ,
[nid] [int] NOT NULL ,
[uid] [int] NOT NULL ,
[subject] [varchar] (64) NOT NULL ,
[comment] [varchar] (8000) NOT NULL ,
[hostname] [varchar] (128) NOT NULL ,
[timestamp] [int] NOT NULL ,
[score] [int] NOT NULL ,
[status] [tinyint] NOT NULL ,
[thread] [varchar] (255) NOT NULL ,
[users] [varchar] (8000) NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[directory] (
[link] [varchar] (255) NOT NULL ,
[name] [varchar] (128) NOT NULL ,
[mail] [varchar] (128) NOT NULL ,
[slogan] [text] NOT NULL ,
[mission] [text] NOT NULL ,
[timestamp] [int] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[feed] (
[fid] [int] NULL ,
[title] [varchar] (255) NOT NULL ,
[url] [varchar] (255) NOT NULL ,
[refresh] [int] NOT NULL ,
[checked] [int] MOT NULL ,
[attributes] [varchar] (255) NULL ,
[link] [varchar] (255) NULL ,
[description] [varchar] (8000) NULL ,
[image] [varchar] (512) NULL ,
[etag] [varchar] (255) NULL ,
[modified] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[forum] (
[nid] [numeric](10, 0) NOT NULL ,
[tid] [numeric](10, 0) NOT NULL ,
[shadow] [numeric](10, 0) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[history] (
[uid] [int] NOT NULL ,
[nid] [int] NOT NULL ,
[timestamp] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[item] (
[iid] [int] NULL ,
[fid] [int] NOT NULL ,
[title] [varchar] (255) NOT NULL ,
[link] [varchar] (255) NOT NULL ,
[author] [varchar] (255) NOT NULL ,
[description] [text] NOT NULL ,
[timestamp] [int] NULL ,
[attributes] [varchar] (255) NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[locales] (
[lid] [int] NULL ,
[location] [varchar] (128) NOT NULL ,
[string] [nvarchar] (4000) NOT NULL ,
[da] [text] NULL ,
[fi] [text] NULL ,
[fr] [text] NULL ,
[en] [text] NULL ,
[es] [text] NULL ,
[nl] [text] NULL ,
[no] [text] NULL ,
[sw] [text] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[menu] (
[name] [varchar] (255) NOT NULL ,
[link] [varchar] (255) NOT NULL ,
[help] [text] NULL ,
[title] [varchar] (255) NOT NULL ,
[parent] [varchar] (255) NOT NULL ,
[weight] [smallint] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[moderation_filters] (
[fid] [numeric](10, 0) NULL ,
[filter] [varchar] (255) NOT NULL ,
[minimum] [smallint] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[moderation_roles] (
[rid] [numeric](4, 0) NOT NULL ,
[mid] [numeric](4, 0) NOT NULL ,
[value] [smallint] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[moderation_votes] (
[mid] [numeric](10, 0) NULL ,
[vote] [varchar] (255) NULL ,
[weight] [smallint] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[node] (
[nid] [numeric](10, 0) NULL ,
[type] [varchar] (16) NOT NULL ,
[title] [varchar] (128) NOT NULL ,
[path] [varchar] (250) NULL ,
[score] [int] NOT NULL ,
[votes] [int] NOT NULL ,
[uid] [int] NOT NULL ,
[status] [int] NOT NULL ,
[created] [int] NOT NULL ,
[comment] [int] NOT NULL ,
[promote] [int] NOT NULL ,
[moderate] [int] NOT NULL ,
[users] [text] NULL ,
[teaser] [text] NOT NULL ,
[body] [text] NOT NULL ,
[changed] [int] NOT NULL ,
[revisions] [text] NULL ,
[static] [int] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[page] (
[nid] [numeric](10, 0) NOT NULL ,
[link] [varchar] (128) NOT NULL ,
[format] [smallint] NOT NULL ,
[description] [varchar] (128) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[url_alias] (
[pid] numeric (10, 0) NOT NULL,
[dst] [varchar] (128) NOT NULL,
[src] [varchar] (128) NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[url_alias] WITH NOCHECK ADD
CONSTRAINT [DF_[url_alias_pid] DEFAULT (0) FOR [pid],
CONSTRAINT [DF_url_alias_dst] DEFAULT ('') FOR [dst],
CONSTRAINT [DF_url_alias_src] DEFAULT ('') FOR [src]
GO
CREATE INDEX [url_alias_src_idx] ON [dbo].[url_alias]([src]) ON [PRIMARY]
CREATE INDEX url_alias_dst_idx ON url_alias(dst);
GO
CREATE TABLE [dbo].[permission] (
[rid] [numeric](4, 0) NOT NULL ,
[perm] [text] NULL ,
[tid] [numeric](4, 0) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[poll] (
[nid] [numeric](4, 0) NOT NULL ,
[runtime] [int] NOT NULL ,
[voters] [text] NOT NULL ,
[active] [numeric](4, 0) NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[poll_choices] (
[chid] [numeric](10, 0) NULL ,
[nid] [numeric](10, 0) NOT NULL ,
[chtext] [varchar] (128) NOT NULL ,
[chvotes] [int] NOT NULL ,
[chorder] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[role] (
[rid] [numeric](10, 0) IDENTITY (1, 1) NOT NULL ,
[name] [varchar] (32) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[search_index] (
[word] [varchar] (50) NOT NULL ,
[lno] [numeric](10, 0) NOT NULL ,
[type] [varchar] (16) NULL ,
[count] [numeric](10, 0) NULL
) ON [PRIMARY]
GO
CREATE TABLE sessions (
[sid] [varchar] (32) NOT NULL,
[uid] [int] NOT NULL,
[hostname] [varchar] (128) NOT NULL,
[timestamp] [integer] NOT NULL,
[session] [text],
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[sequences] (
[name] [varchar] (255) NOT NULL ,
[id] [numeric](10, 0) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[node_counter] (
[nid] [int] NOT NULL ,
[totalcount] [numeric](20, 0) NOT NULL ,
[daycount] [numeric](4, 0) NOT NULL ,
[timestamp] [numeric](4, 0) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[system] (
[filename] [varchar] (255) NOT NULL ,
[name] [varchar] (255) NOT NULL ,
[type] [varchar] (255) NOT NULL ,
[description] [varchar] (255) NOT NULL ,
[status] [int] NOT NULL ,
[throttle] [smallint] NOT NULL ,
[bootstrap] [int] NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[term_data] (
[tid] [numeric](10, 0) NOT NULL ,
[vid] [numeric](10, 0) NOT NULL ,
[name] [varchar] (255) NOT NULL ,
[description] [text] NULL ,
[weight] [smallint] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[term_hierarchy] (
[tid] [numeric](4, 0) NOT NULL ,
[parent] [numeric](4, 0) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[term_node] (
[nid] [numeric](4, 0) NOT NULL ,
[tid] [numeric](4, 0) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[term_relation] (
[tid1] [numeric](4, 0) NOT NULL ,
[tid2] [numeric](4, 0) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[term_synonym] (
[tid] [numeric](10, 0) NOT NULL ,
[name] [varchar] (255) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[users] (
[uid] [numeric](10, 0) NULL ,
[name] [varchar] (60) NOT NULL ,
[pass] [varchar] (32) NOT NULL ,
[mail] [varchar] (64) NULL ,
[mode] [smallint] NOT NULL ,
[sort] [smallint] NULL ,
[threshold] [smallint] NULL ,
[theme] [varchar] (255) NULL ,
[signature] [varchar] (255) NULL ,
[timestamp] [float] NOT NULL ,
[status] [smallint] NOT NULL ,
[timezone] [varchar] (8) NULL ,
[language] [char] (2) NULL ,
[init] [varchar] (128) NULL ,
[data] [varchar] (8000) NULL ,
[rid] [int] NOT NULL
)
--ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[users_uid_seq] (
[id] [int] IDENTITY (1, 1) NOT NULL ,
[vapor] [int] NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[variable] (
[name] [varchar] (48) NOT NULL ,
[value] [varchar] (8000) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo].[vocabulary] (
[vid] [numeric](10, 0) NULL ,
[name] [varchar] (255) NOT NULL ,
[description] [text] NULL ,
[relations] [tinyint] NOT NULL ,
[hierarchy] [tinyint] NOT NULL ,
[multiple] [tinyint] NOT NULL ,
[required] [tinyint] NOT NULL ,
[nodes] [text] NULL ,
[weight] [smallint] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[watchdog] (
[wid] [int] IDENTITY (1, 1) NOT NULL ,
[uid] [int] NOT NULL ,
[type] [varchar] (16) NOT NULL ,
[message] [text] NOT NULL ,
[link] [varchar] (255) NOT NULL ,
[location] [varchar] (128) NOT NULL ,
[hostname] [varchar] (128) NOT NULL ,
[timestamp] [int] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[role] WITH NOCHECK ADD
CONSTRAINT [PK_role] PRIMARY KEY CLUSTERED
(
[rid]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[watchdog] WITH NOCHECK ADD
PRIMARY KEY CLUSTERED
(
[wid]
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[cache] WITH NOCHECK ADD
CONSTRAINT [DF_cache_created] DEFAULT (0) FOR [created]
GO
CREATE INDEX [forum_tid_idx] ON [dbo].[forum]([tid]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[node] WITH NOCHECK ADD
CONSTRAINT [DF_node_score] DEFAULT (0) FOR [score],
CONSTRAINT [DF_node_votes] DEFAULT (0) FOR [votes],
CONSTRAINT [DF_node_uid] DEFAULT (0) FOR [uid],
CONSTRAINT [DF_node_status] DEFAULT (1) FOR [status],
CONSTRAINT [DF_node_created] DEFAULT (0) FOR [created],
CONSTRAINT [DF_node_comment] DEFAULT (2) FOR [comment],
CONSTRAINT [DF_node_promote] DEFAULT (0) FOR [promote],
CONSTRAINT [DF_node_moderate] DEFAULT (0) FOR [moderate],
CONSTRAINT [DF_node_changed] DEFAULT (0) FOR [changed],
CONSTRAINT [DF_node_static] DEFAULT (0) FOR [static]
GO
CREATE INDEX [IX_role] ON [dbo].[role]([rid]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[term_data] WITH NOCHECK ADD
CONSTRAINT [DF_term_data_vid] DEFAULT (0) FOR [vid]
GO
ALTER TABLE [dbo].[users] WITH NOCHECK ADD
CONSTRAINT [DF_users_mode] DEFAULT (0) FOR [mode],
CONSTRAINT [DF_users_sort] DEFAULT (0) FOR [sort],
CONSTRAINT [DF_users_threshold] DEFAULT (0) FOR [threshold],
CONSTRAINT [DF_users_status] DEFAULT (0) FOR [status],
CONSTRAINT [DF_users_timestamp] DEFAULT (0) FOR [timestamp],
CONSTRAINT [DF_users_rid] DEFAULT (0) FOR [rid],
CONSTRAINT [DF_users_pass] DEFAULT ('') FOR [pass],
CONSTRAINT [DF_users_homepage] DEFAULT ('') FOR [homepage],
CONSTRAINT [DF_users_theme] DEFAULT ('') FOR [theme],
CONSTRAINT [DF_users_signature] DEFAULT ('') FOR [signature],
CONSTRAINT [DF_users_language] DEFAULT ('') FOR [language]
GO
CREATE INDEX [IX_sid] ON [dbo].[sessions]([sid]) ON [PRIMARY]
GO
CREATE INDEX [IX_users] ON [dbo].[users]([uid]) ON [PRIMARY]
GO
CREATE INDEX [IX_timestamp] ON [dbo].[users]([timestamp]) ON [PRIMARY]
GO
CREATE INDEX [sessions_sid_idx] ON [dbo].[sessions]([sid]) ON [PRIMARY]
GO
CREATE INDEX [users_timestamp_idx] ON [dbo].[users]([timestamp]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[watchdog] WITH NOCHECK ADD
CONSTRAINT [DF__watchdog__uid__41EDCAC5] DEFAULT ('0') FOR [uid],
CONSTRAINT [DF__watchdog__type__42E1EEFE] DEFAULT ('') FOR [type],
CONSTRAINT [DF__watchdog__messag__43D61337] DEFAULT ('') FOR [message],
CONSTRAINT [DF__watchdog__link__44CA3770] DEFAULT ('') FOR [link],
CONSTRAINT [DF__watchdog__locati__45BE5BA9] DEFAULT ('') FOR [location],
CONSTRAINT [DF__watchdog__hostna__46B27FE2] DEFAULT ('') FOR [hostname],
CONSTRAINT [DF__watchdog__timest__47A6A41B] DEFAULT ('0') FOR [timestamp]
GO
--
-- Insert some default values
--
INSERT INTO system VALUES ('modules/admin.module','admin','module','',1,0,0);
INSERT INTO system VALUES ('modules/block.module','block','module','',1,0,0);
INSERT INTO system VALUES ('modules/comment.module','comment','module','',1,0,0);
INSERT INTO system VALUES ('modules/help.module','help','module','',1,0,0);
INSERT INTO system VALUES ('modules/node.module','node','module','',1,0,0);
INSERT INTO system VALUES ('modules/page.module','page','module','',1,0,0);
INSERT INTO system VALUES ('modules/story.module','story','module','',1,0,0);
INSERT INTO system VALUES ('modules/taxonomy.module','taxonomy','module','',1,0,0);
INSERT INTO system VALUES ('themes/xtemplate/xtemplate.theme','xtemplate','theme','Internet explorer, Netscape, Opera',1,0,0);
INSERT INTO variable(name,value) VALUES('update_start', 's:10:"2004-02-21";');
INSERT INTO variable(name,value) VALUES('theme_default','s:9:"xtemplate";');
INSERT INTO users(uid,name,mail,rid) VALUES(0,'','','1');
INSERT INTO blocks(module,delta,status,custom,region,weight,path) VALUES('user', 0, 1, 0, 1, 0, '');
INSERT INTO blocks(module,delta,status,custom,region,weight,path) VALUES('user', 1, 1, 0, 1, 0, '');
---
--- Functions. Functions first available in SQL Server 2000. GREATEST() used by forum.module, tracker.module at the moment.
---
GO
CREATE FUNCTION GREATEST (@a int, @b int)
RETURNS int AS
BEGIN
IF (@a > @b)
BEGIN
RETURN @a;
END
RETURN @b;
END
This diff is collapsed.
......@@ -266,7 +266,7 @@ function drupal_not_found() {
menu_execute_active_handler();
}
else {
print theme("page", '<h1>'. t('Page not found') .'</h1>');
print theme('page', '', t('Page not found'));
}
}
......@@ -333,27 +333,25 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
fwrite($fp, $request);
// Fetch response.
while (!feof($fp) && $data = fgets($fp)) {
$response[] = $data;
$response = '';
while (!feof($fp) && $data = fread($fp, 1024)) {
$response .= $data;
}
fclose($fp);
// Parse response.
list($protocol, $code, $text) = explode(' ', trim(array_shift($response)), 3);
list($headers, $result->data) = explode("\r\n\r\n", $response, 2);
$headers = preg_split("/\r\n|\n|\r/", $headers);
list($protocol, $code, $text) = explode(' ', trim(array_shift($headers)), 3);
$result->headers = array();
$result->data = '';
// Parse headers.
while ($line = trim(array_shift($response))) {
if ($line == '') {
break;
}
while ($line = trim(array_shift($headers))) {
list($header, $value) = explode(':', $line, 2);
$result->headers[$header] = trim($value);
}
$result->data = implode('', $response);
$responses = array(
100 => 'Continue', 101 => 'Switching Protocols',
200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content',
......@@ -404,15 +402,6 @@ function error_handler($errno, $message, $filename, $line, $variables) {
}
}
function throttle($type, $rate) {
if (!user_access("access administration pages")) {
if ($throttle = db_fetch_object(db_query("SELECT * FROM {watchdog} WHERE type = '%s' AND hostname = '%s' AND %d - timestamp < %d", $type, $_SERVER['REMOTE_ADDR'], time(), $rate))) {
watchdog("warning", "throttle: '". $_SERVER['REMOTE_ADDR'] ."' exceeded submission rate - $throttle->type");
die(message_throttle());
}
}
}
function _fix_gpc_magic(&$item, $key) {
if (is_array($item)) {
array_walk($item, '_fix_gpc_magic');
......@@ -482,9 +471,6 @@ function message_na() {
return t("n/a");
}
function message_throttle() {
return t("You exceeded the maximum submission rate. Please wait a few minutes and try again.");
}
/* @} */
function locale_init() {
......@@ -561,7 +547,7 @@ function drupal_specialchars($input, $quotes = ENT_NOQUOTES) {
*/
function valid_email_address($mail) {
$user = '[a-zA-Z0-9_\-\.\+\^!#\$%&*+\/\=\?\`\|\{\}~\']+';
$domain = '(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9]\.?)+';
$domain = '(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.?)+';
$ipv4 = '[0-9]{1,3}(\.[0-9]{1,3}){3}';
$ipv6 = '[0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7}';
......@@ -915,7 +901,7 @@ function format_name($object) {
*/
if (strlen($object->name) > 20) {
$name = substr($object->name, 0, 15) ."...";
$name = truncate_utf8($object->name, 15) ."...";
}
else {
$name = $object->name;
......@@ -950,11 +936,11 @@ function format_name($object) {
* @defgroup from Form generation
* @{
*/
function form($form, $method = "post", $action = 0, $options = 0) {
function form($form, $method = "post", $action = NULL, $attributes = NULL) {
if (!$action) {
$action = request_uri();
}
return "<form action=\"$action\" method=\"$method\"". drupal_attributes($options) .">\n$form\n</form>\n";
return "<form action=\"$action\" method=\"$method\"". drupal_attributes($attributes) .">\n$form\n</form>\n";
}
function form_item($title, $value, $description = NULL, $id = NULL) {
......@@ -966,20 +952,28 @@ function form_group($legend, $group, $description = NULL) {
}
function form_radio($title, $name, $value = 1, $checked = 0, $description = NULL, $attributes = NULL) {
return theme("form_element", NULL, "<input type=\"radio\" class=\"form-radio\" name=\"edit[$name]\" id=\"edit-$name-$value\" value=\"$value\"". ($checked ? " checked=\"checked\"" : "") . drupal_attributes($attributes) .' />'. (!is_null($title) ? " <label for=\"edit-$name-$value\">$title</label>" : ''), $description);
$element = "<input type=\"radio\" class=\"form-radio\" name=\"edit[$name]\" value=\"$value\"". ($checked ? " checked=\"checked\"" : "") . drupal_attributes($attributes) .' />';
if (!is_null($title)) {
$element = "<label class=\"option\">$element $title</label>";
}
return theme('form_element', NULL, $element, $description);
}
function form_radios($title, $name, $value, $options, $description = NULL) {
if (count($options) > 0) {
foreach ($options as $key => $choice) {
$choices .= "<input type=\"radio\" class=\"form-radio\" name=\"edit[$name]\" id=\"edit-$name-$key\" value=\"$key\"". ($key == $value ? " checked=\"checked\"" : "") ." /> <label for=\"edit-$name-$key\">$choice</label><br />";
$choices .= "<label class=\"option\"><input type=\"radio\" class=\"form-radio\" name=\"edit[$name]\" value=\"$key\"". ($key == $value ? " checked=\"checked\"" : "") ." /> $choice</label><br />";
}
return theme("form_element", $title, $choices, $description);
return theme('form_element', $title, $choices, $description);
}
}
function form_checkbox($title, $name, $value = 1, $checked = 0, $description = NULL, $attributes = NULL) {
return form_hidden($name, 0) . theme("form_element", NULL, "<input type=\"checkbox\" class=\"form-checkbox\" name=\"edit[$name]\" id=\"edit-$name\" value=\"". $value ."\"". ($checked ? " checked=\"checked\"" : "") . drupal_attributes($attributes) .' />' . (!is_null($title) ? " <label for=\"edit-$name\">$title</label>" : ''), $description);
$element = "<input type=\"checkbox\" class=\"form-checkbox\" name=\"edit[$name]\" id=\"edit-$name\" value=\"". $value ."\"". ($checked ? " checked=\"checked\"" : "") . drupal_attributes($attributes) .' />';
if (!is_null($title)) {
$element = "<label class=\"option\">$element $title</label>";
}
return form_hidden($name, 0) . theme('form_element', NULL, $element, $description);
}
function form_textfield($title, $name, $value, $size, $maxlength, $description = NULL, $attributes = NULL) {
......@@ -1092,18 +1086,19 @@ function url($url = NULL, $query = NULL, $fragment = NULL, $absolute = NULL) {
}
}
function drupal_attributes($attributes = NULL) {
if (is_array($attributes)) {
function drupal_attributes($attributes = array()) {
if (count($attributes)) {
$t = array();
foreach ($attributes as $key => $value) {
$t[] = "$key=\"$value\"";
}
return " ". implode($t, " ");
}
}
function l($text, $url, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = NULL) {
if ($url == $_GET['q']) {
if (drupal_get_normal_path($url) == $_GET['q']) {
if (isset($attributes['class'])) {
$attributes['class'] .= ' active';
}
......@@ -1222,6 +1217,31 @@ function drupal_xml_parser_create(&$data) {
return $xml_parser;
}
/**
* UTF-8-safe string truncation
* If the end position is in the middle of a UTF-8 sequence, it scans backwards
* until the beginning of the byte sequence.
*
* Use this function whenever you want to chop off a string at an unsure
* location. On the other hand, if you're sure that you're splitting on a
* character boundary (e.g. after using strpos or similar), you can safely use
* substr() instead.
*
* @param $string The string to truncate
* @param $len An upper limit on the returned string length.
*/
function truncate_utf8($string, $len) {
$slen = strlen($string);
if ($slen <= $len) {
return $string;
}
if ((ord($string[$len]) < 0x80) || (ord($string[$len]) >= 0xC0)) {
return substr($string, 0, $len);
}
while (ord($string[--$len]) < 0xC0) {};
return substr($string, 0, $len);
}
include_once "includes/theme.inc";
include_once "includes/pager.inc";
include_once "includes/menu.inc";
......@@ -1233,7 +1253,7 @@ function drupal_xml_parser_create(&$data) {
set_error_handler("error_handler");
// spit out the correct charset http header
header("Content-Type: text/html; charset=utf-8");
drupal_set_header("Content-Type: text/html; charset=utf-8");
// initialize the _GET["q"] prior to loading the modules and invoking their 'init' hook:
if (!empty($_GET["q"])) {
......
......@@ -14,7 +14,6 @@
# $db_url = "mysql://user:password@hostname/database";
# $db_url = "pgsql://user:password@hostname/database";
# $db_url = "mssql://user:password@hostname/database";
$db_url = "mysql://drupal:drupal@localhost/drupal";
# If $db_prefix is specified all database table names will be
......
......@@ -11,13 +11,6 @@
define('FILE_DOWNLOADS_PRIVATE', 2);
define('FILE_SEPARATOR', PHP_OS == 'WINNT' ? '\\' : '/');
// Required for file uploads to work with PHP 4.2
define('UPLOAD_ERR_OK', 0);
define('UPLOAD_ERR_INI_SIZE', 1);
define('UPLOAD_ERR_FORM_SIZE', 2);
define('UPLOAD_ERR_PARTIAL', 3);
define('UPLOAD_ERR_NO_FILE', 4);
/**
* Create the download path to a file.
*/
......@@ -182,11 +175,17 @@ function file_copy(&$source, $dest = 0, $replace = 0) {
// and find a new filename.
$pos = strrpos($basename, '.');
$name = substr($basename, 0, $pos);
$ext = substr($basename, $pos);
if ($pos = strrpos($basename, '.')) {
$name = substr($basename, 0, $pos);
$ext = substr($basename, $pos);
}
else {
$name = $basename;
}
$counter = 0;
do {
$dest = $directory . FILE_SEPARATOR . $name .'_'. $counter++ . $ext;
$counter++;
} while (file_exists($dest));
}
......@@ -256,13 +255,18 @@ function file_save_upload($source, $dest = 0, $replace = 0) {
// Check for file upload errors.
switch ($file->error) {
case UPLOAD_ERR_PARTIAL:
case UPLOAD_ERR_NO_FILE:
case 0: // UPLOAD_ERR_OK
break;
case 1: // UPLOAD_ERR_INI_SIZE
case 2: // UPLOAD_ERR_FORM_SIZE
drupal_set_message(t("file upload failed: file size too big."), 'error');
return 0;
case 3: // UPLOAD_ERR_PARTIAL
case 4: // UPLOAD_ERR_NO_FILE
drupal_set_message(t("file upload failed: incomplete upload."), 'error');
return 0;
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
drupal_set_message(t("file upload failed: file size too big."), 'error');
default: // Unknown error
drupal_set_message(t("file upload failed: unkown error."), 'error');
return 0;
}
......@@ -303,7 +307,7 @@ function file_transfer($source, $headers) {
// Transfer file in 1024 byte chunks to save memory usage.
$fd = fopen($source, 'rb');
while (!feof($fd)) {
print fgets($fd);
print fgets($fd, 1024);
}
fclose($fd);
exit();
......
......@@ -170,7 +170,7 @@ function pager_next($text, $limit, $element = 0, $n = 1, $attributes = array())
function pager_last($text, $limit, $element = 0, $attributes = array()) {
global $pager_from_array, $pager_total;
$from_new = pager_load_array(($pager_total[$element] - $limit), $element, $pager_from_array);
$from_new = pager_load_array(($pager_total[$element] - ($pager_total[$element] % $limit)), $element, $pager_from_array);
if ($from_new[$element] < ($pager_from_array[$element] + $limit)) {
return pager_next($text, $limit, $element, 1, $attributes);
}
......
......@@ -31,6 +31,7 @@ function tablesort($cell, $header) {
// special formatting for the currently sorted column header
if ($cell['data'] == $ts['order']) {
$ts['sort'] = (($ts['sort'] == 'asc') ? 'desc' : 'asc');
$cell['class'] = 'cell-highlight';
$image = '&nbsp;<img src="' . theme('image', 'arrow-' . $ts['sort'] . '.gif') . '" alt="'. t('sort icon') .'" />';
$title = ($ts['sort'] == 'asc' ? t("sort ascending") : t("sort descending"));
......@@ -89,12 +90,12 @@ function tablesort_get_order_sql($header, $order) {
function tablesort_get_sort($headers) {
if ($_GET['sort']) {
return ($_GET['sort'] == 'desc') ? 'asc' : 'desc';
return ($_GET['sort'] == 'desc') ? 'desc' : 'asc';
}
// user has not specified a sort. check module for default and if none, use 'asc'
else {
foreach ($headers as $header) {
if (isset($header['sort'])) {
if (is_array($header) && isset($header['sort'])) {
return $header['sort'];
}
}
......
......@@ -285,7 +285,7 @@ function theme_form_element($title, $value, $description = NULL, $id = NULL) {
}
else {
if ($id) {
$title = "<label for=\"$id\" />";
$title = "<label for=\"$id\"></label>";
// TODO: does this make sense to do?
}
}
......@@ -361,7 +361,7 @@ function theme_table($header, $rows, $attributes = NULL) {
* @return a string containing the @a box output.
*/
function theme_box($title, $content, $region = 'main') {
$output = "<h2 class=\"title\">$title</h2><p>$content</p>";
$output = "<h2 class=\"title\">$title</h2><div>$content</div>";
return $output;
}
......
......@@ -150,6 +150,9 @@ li a.active {
.form-item label {
font-weight: bold;
}
.form-item label.option {
font-weight: normal;
}
.form-submit {
margin: 0.5em 0;
}
......@@ -209,18 +212,13 @@ li a.active {
.poll .bar {
height: 1em;
margin: 1px 0;
}
.poll .bar .background {
background-color: #ddd;
float: left;
height: 1em;
margin-left: -1px;
}
.poll .bar .foreground {
background-color: #000;
float: left;
height: 1em;
margin-right: -1px;
clear: left;
float: left;
}
.poll .links {
text-align: center;
......@@ -239,6 +237,9 @@ li a.active {
margin: 0 auto;
display: table;
}
.node-form .poll-form fieldset {
display: block;
}
.more-link {
text-align: right;
}
......
......@@ -4,7 +4,7 @@
function aggregator_help($section) {
switch ($section) {
case 'admin/help#aggregator':
$output = t("
return t("
<p>Thousands of web sites, especially news sites and weblogs, syndicate their most recent site content for others to display. The syndicated content always includes titles, also known as headlines, for the newest published stories. Each headline acts as a direct link to the stories on the remote site. Along with the headline, most sites typically provide either the first few paragraphs of the story or a short summary. Many individuals use client-based news aggregators on their personal computer to aggregate content, such as <a href=\"%amphetadesk\">Amphetadesk</a>.</p>
<p>Drupal also has a news aggregator built in as a standard feature. With it, you can subscribe to feeds from other sites and display their content for your site users. Simply enable the aggregator module in site administration and enter the feeds that you choose.</p>
<h3>What do I need to subscribe to a feed?</h3>
......@@ -52,7 +52,7 @@ function aggregator_help($section) {
<p>Drupal automatically generates an OPML feed file that is available by selecting the XML icon on the News Sources page.</p>
<h3>Technical details</h3>
<p>When fetching feeds Drupal supports conditional GETs, this reduces the bandwidth usage for feeds that have not been updated since the last check.</p>
<p>If a feed is permanently moved to a new location Drupal will automatically update the feed URL to the new address.</p>", array("%amphetadesk" => "<a href=\"http://www.disobey.com/amphetadesk/\">AmphetaDesk</a>", "%rss" => "<a href=\"http://groups.yahoo.com/group/rss-dev/files/specification.html\">Rich Site Summary</a>", "%slashdot-rss" => "<a href=\"http://slashdot.org/slashdot.rdf\">http://slashdot.org/slashdot.rdf</a>", "%syndic8" => "<a href=\"http://www.syndic8.com/\">Syndic8</a>", "%rss-what" => "<a href=\"http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html\">What is RSS</a>", "%rss-evolution" => "<a href=\"http://www.webreference.com/authoring/languages/xml/rss/1/\">The Evolution of RSS</a>", "%admin-news" => l(t("RSS/RDF"), "admin/syndication/news"), "%new-feed" => l(t("new feed"), "admin/syndication/news/add/feed"), "%update-items" => l(t("update items"), "admin/syndication/news")));
<p>If a feed is permanently moved to a new location Drupal will automatically update the feed URL to the new address.</p>", array("%amphetadesk" => "http://www.disobey.com/amphetadesk/", "%rss" => "http://blogs.law.harvard.edu/tech/rss", "%slashdot-rss" => "http://slashdot.org/slashdot.rdf", "%syndic8" => "http://www.syndic8.com/", "%rss-what" => "http://www.xml.com/pub/a/2002/12/18/dive-into-xml.html", "%rss-evolution" => "http://www.webreference.com/authoring/languages/xml/rss/1/", "%admin-news" => url("admin/syndication/news"), "%new-feed" => url("admin/syndication/news/add/feed"), "%update-items" => url("admin/syndication/news")));
case 'admin/system/modules#description':
return t("Used to aggregate syndicated content (RSS and RDF).");
case 'admin/system/modules/aggregator':
......@@ -130,7 +130,7 @@ function aggregator_bundle_block($attributes) {
$where[] = "attributes LIKE '%". check_query(trim($key)) ."%'";
}
$result = db_query_range("SELECT * FROM {item} WHERE ". implode(" OR ", $where) ." ORDER BY timestamp DESC", 0, variable_get("aggregator_block_limit", 15));
$result = db_query_range("SELECT * FROM {item} WHERE ". implode(" OR ", $where) ." ORDER BY timestamp DESC, iid DESC", 0, variable_get("aggregator_block_limit", 15));
}
$items = array();
......@@ -142,7 +142,7 @@ function aggregator_bundle_block($attributes) {
}
function aggregator_feed_block($feed) {
$result = db_query_range("SELECT * FROM {item} WHERE fid = %d ORDER BY timestamp DESC ", $feed->fid, 0, variable_get("aggregator_block_limit", 15));
$result = db_query_range("SELECT * FROM {item} WHERE fid = %d ORDER BY timestamp DESC, iid DESC", $feed->fid, 0, variable_get("aggregator_block_limit", 15));
$items = array();
while ($item = db_fetch_object($result)) {
......@@ -215,6 +215,7 @@ function aggregator_get_feeds($attributes = 0) {
function aggregator_remove($feed) {
db_query("DELETE FROM {item} WHERE fid = %d", $feed["fid"]);
db_query("UPDATE {feed} SET checked = 0, etag = '', modified = 0 WHERE fid = %d", $feed['fid']);
drupal_set_message(t("removed news items from '%site'.", array("%site" => $feed["title"])));
}
......@@ -368,7 +369,7 @@ function aggregator_parse_feed(&$data, $feed) {
xml_parser_free($xml_parser);
// initialize the translation table:
$tt = array_flip(get_html_translation_table(HTML_ENTITIES));
$tt = array_flip(get_html_translation_table(HTML_SPECIALCHARS));
$tt["&apos;"] = "'";
/*
......@@ -397,7 +398,7 @@ function aggregator_parse_feed(&$data, $feed) {
$title = $item["TITLE"];
}
else {
$title = preg_replace('/^(.*)[^\w;&].*?$/', "\\1", substr($item["DESCRIPTION"], 0, 40));
$title = preg_replace('/^(.*)[^\w;&].*?$/', "\\1", truncate_utf8($item["DESCRIPTION"], 40));
}
/*
......@@ -597,7 +598,7 @@ function aggregator_view() {
}
function aggregator_tag() {
$result = db_query_range("SELECT i.*, f.title AS feed FROM {item} i INNER JOIN {feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC", 0, 50);
$result = db_query_range("SELECT i.*, f.title AS feed FROM {item} i INNER JOIN {feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC", 0, 50);
$header = array(t("date"), t("feed"), t("news item"));
while ($item = db_fetch_object($result)) {
......@@ -663,7 +664,7 @@ function aggregator_admin() {
}
function aggregator_page_last() {
$result = db_query_range("SELECT i.*, f.title AS ftitle, f.link AS flink FROM {item} i INNER JOIN {feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC", 0, variable_get("aggregator_page_limit", 75));
$result = db_query_range("SELECT i.*, f.title AS ftitle, f.link AS flink FROM {item} i INNER JOIN {feed} f ON i.fid = f.fid ORDER BY i.timestamp DESC, i.iid DESC", 0, variable_get("aggregator_page_limit", 75));
$output = "<div id=\"aggregator\">";
while ($item = db_fetch_object($result)) {
......@@ -679,7 +680,7 @@ function aggregator_page_feed($fid) {
$info = theme('aggregator_feed', $feed);
$result = db_query_range("SELECT * FROM {item} WHERE fid = %d ORDER BY timestamp DESC", $fid, 0, variable_get("aggregator_page_limit", 75));
$result = db_query_range("SELECT * FROM {item} WHERE fid = %d ORDER BY timestamp DESC, iid DESC", $fid, 0, variable_get("aggregator_page_limit", 75));
while ($item = db_fetch_object($result)) {
$content .= theme('aggregator_page_item', $item);
}
......@@ -696,7 +697,7 @@ function aggregator_page_bundle($bid) {
$keys = explode(",", $bundle->attributes);
foreach ($keys as $key) $where[] = "i.attributes LIKE '%". trim($key) ."%'";
$result = db_query_range("SELECT i.*, f.title AS ftitle, f.link AS flink FROM {item} i, {feed} f WHERE (". implode(" OR ", $where) .") AND i.fid = f.fid ORDER BY timestamp DESC", 0, variable_get("aggregator_page_limit", 75));
$result = db_query_range("SELECT i.*, f.title AS ftitle, f.link AS flink FROM {item} i, {feed} f WHERE (". implode(" OR ", $where) .") AND i.fid = f.fid ORDER BY timestamp DESC, iid DESC", 0, variable_get("aggregator_page_limit", 75));
while ($item = db_fetch_object($result)) {
$content .= theme('aggregator_page_item', $item);
......@@ -832,7 +833,7 @@ function theme_aggregator_feed($feed) {
function theme_aggregator_block_item($item, $feed = 0) {
global $user;
if ($user->uid && module_exist("blog") && user_access("maintain personal blog")) {
if ($user->uid && module_exist("blog") && user_access("edit own blog")) {
$output .= "<div class=\"icon\">". l("<img src=\"". theme("image", "blog.gif") ."\" alt=\"". t("blog it") ."\" title=\"". t("blog it") ."\" />", "node/add/blog", array("title" => t("Comment on this news item in your personal blog."), "class" => "blog-it"), "iid=$item->iid") ."</div>";
}
......
This diff is collapsed.
......@@ -82,7 +82,7 @@ function archive_calendar($original = 0) {
// Generate calendar header:
$output .= "\n<!-- calendar -->\n";
$output .= "<div class=\"calendar\">";
$output .= "<table>\n";
$output .= "<table summary=\"". t('A calendar to browse the archives') .".\">\n";
$output .= " <tr><td colspan=\"7\" class=\"header-month\">". l("&laquo;", "archive/". date("Y/m/d", $prev)) ." ". format_date($requested, "custom", "F") . date(" Y", $requested) ." ". ($nextmonth <= time() ? l("&raquo;", "archive/". date("Y/m/d", $next)) : "&nbsp;") ."</td></tr>\n";
// First day of week (0 => Sunday, 1 => Monday, ...)
......
<?php
// $Id$
function archive_help($section) {
$output = "";
switch ($section) {
case 'admin/system/modules#description':
$output = t("Displays a calendar to navigate old content.");
break;
case 'admin/system/modules/archive':
$output = t("Choose the starting \"day of the week\" for the displayed calendar block.");
break;
}
return $output;
}
function archive_calendar($original = 0) {
global $user;
$edit = $_POST["edit"];
// Extract today's date:
$offset = time() + $user->timezone;
$start_of_today = mktime(0, 0, 0, date("n", $offset), date("d", $offset), date("Y", $offset)) + $user->timezone;
$end_of_today = mktime(23, 59, 59, date("n", $offset), date("d", $offset), date("Y", $offset)) + $user->timezone;
// Extract the requested date:
if ($edit["year"] && $edit["month"] && $edit["day"]) {
$year = $edit["year"];
$month = $edit["month"];
$day = $edit["day"];
$requested = mktime(0, 0, 0, $month, $day, $year) + $user->timezone;
}
else if (arg(0) == "archive" && arg(3)) {
$year = arg(1);
$month = arg(2);
$day = arg(3);
$requested = mktime(0, 0, 0, $month, $day, $year) + $user->timezone;
}
else {
$year = date("Y", time());
$month = date("n", time());
$day = date("d", time());
$requested = $end_of_today + $user->timezone;
}
$start_of_month = mktime(0, 0, 0, $month, 1, $year);
// Extract first day of the month:
$first = date("w", $start_of_month);
// Extract last day of the month:
$last = date("t", $start_of_month);
$end_of_month = mktime(23, 59, 59, $month, $last, $year);
$cache = cache_get("archive:calendar:$day-$month-$year");
if (!empty($cache)) {
return $cache->data;
}
// Calculate previous and next months dates and check for shorter months (28/30 days)
$prevmonth = mktime(23, 59, 59, $month - 1, 1, $year);
$prev = mktime(23, 59, 59, $month - 1, min(date("t", $prevmonth), $day), $year);
$nextmonth = mktime(23, 59, 59, $month + 1, 1, $year);
$next = mktime(23, 59, 59, $month + 1, min(date("t", $nextmonth), $day), $year);
$result = db_query("SELECT created FROM {node} WHERE status = 1 AND created > $start_of_month AND created < $end_of_month");
$days_with_posts = array();
while ($day_with_post = db_fetch_object($result)) {
$days_with_posts[] = date("j", $day_with_post->created + $user->timezone);
}
$days_with_posts = array_unique($days_with_posts);
// Generate calendar header:
$output .= "\n<!-- calendar -->\n";
$output .= "<div class=\"calendar\">";
$output .= "<table>\n";
$output .= " <tr><td colspan=\"7\" class=\"header-month\">". l("&laquo;", "archive/". date("Y/m/d", $prev)) ." ". format_date($requested, "custom", "F") . date(" Y", $requested) ." ". ($nextmonth <= time() ? l("&raquo;", "archive/". date("Y/m/d", $next)) : "&nbsp;") ."</td></tr>\n";
// First day of week (0 => Sunday, 1 => Monday, ...)
$cday = $weekstart = variable_get("default_firstday", 0);
// Last day of week
($weekstart - 1 == -1) ? $lastday = 6 : $lastday = $weekstart - 1;
// Generate the days of the week:
$firstcolumn = mktime(0, 0, 0, 3, 20 + $weekstart, 1994);
$output .= " <tr class=\"header-week\">";
$days = array(t('Su'), t('Mo'), t('Tu'), t('We'), t('Th'), t('Fr'), t('Sa'));
for ($i = 0; $i < 7; $i++) {
$output .= "<td>". $days[$cday] . "</td>";
$cday = ($cday < 6 ? $cday+1 : 0);
}
$output .= "</tr>\n";
// Initialize temporary variables:
$nday = 1;
$sday = $first;
// Loop through all the days of the month:
while ($nday <= $last) {
// Set up blank days for first week of the month:
if ($first != $weekstart) {
$blankdays = ($first - $weekstart + 7) % 7;
$output .= " <tr class=\"row-week\"><td class=\"day-blank\" colspan=\"$blankdays\">&nbsp;</td>\n";
$first = $weekstart;
}
// Start every week on a new line:
if ($sday == $weekstart) {
$output .= " <tr class=\"row-week\">\n";
}
// Print one cell:
$date = mktime(0, 0, 0, $month, $nday, $year) + $user->timezone;
if (in_array($nday, $days_with_posts)) {
$daytext = l($nday, "archive/$year/$month/$nday");
$dayclass = "day-link";
}
else {
$daytext = "<div>$nday</div>";
$dayclass = "day-normal";
}
if ($date == $requested) {
$output .= " <td class=\"day-selected\">$daytext</td>\n";
}
else if ($date == $start_of_today) {
$output .= " <td class=\"day-today\">$daytext</td>\n";
}
else if ($date > $end_of_today) {
$output .= " <td class=\"day-future\">$daytext</td>\n";
}
else {
$output .= " <td class=\"$dayclass\">$daytext</td>\n";
}
// Start every week on a new line:
if ($sday == $lastday) {
$output .= " </tr>\n";
}
// Update temporary variables:
$sday++;
$sday = $sday % 7;
$nday++;
}
// Complete the calendar:
if ($sday != $weekstart) {
$end = (7 - $sday + $weekstart) % 7;
$output .= " <td class=\"day-blank\" colspan=\"$end\">&nbsp;</td>\n </tr>\n";
}
$output .= "</table></div>\n\n";
cache_set("archive:calendar:$day-$month-$year", $output, 1);
return $output;
}
function archive_block($op = "list", $delta = 0) {
global $date;
if ($op == "list") {
$blocks[0]["info"] = t("Calendar to browse archives");
return $blocks;
}
else if (user_access("access content")) {
switch ($delta) {
case 0:
$block["subject"] = t("Browse archives");
$block["content"] = archive_calendar();
return $block;
}
}
}
function archive_link($type) {
$links = array();
if ($type == "page" && user_access("access content")) {
$links[] = l(t("archives"), "archive", array("title" => t("Read the older content in our archive.")));
}
if ($type == "system") {
if (user_access("access content")) {
menu("archive", t("archives"), "archive_page", 0, MENU_HIDE);
}
}
return $links;
}
function archive_page() {
global $date, $month, $year, $meta, $user;
$op = $_POST["op"];
$edit = $_POST["edit"];
if ($op == t("Show")) {
$year = $edit["year"];
$month = $edit["month"];
$day = $edit["day"];
}
else {
$year = arg(1);
$month = arg(2);
$day = arg(3);
}
$date = mktime(0, 0, 0, $month, $day, $year) - $user->timezone;
$date_end = mktime(0, 0, 0, $month, $day + 1, $year) - $user->timezone;
/*
** Prepare the values of the form fields:
*/
$years = drupal_map_assoc(range(2000, 2005));
$months = array(1 => t("January"), 2 => t("February"), 3 => t("March"), 4 => t("April"), 5 => t("May"), 6 => t("June"), 7 => t("July"), 8 => t("August"), 9 => t("September"), 10 => t("October"), 11 => t("November"), 12 => t("December"));
$days = drupal_map_assoc(range(0, 31));
$start = "<div class=\"container-inline\">";
$start .= form_select("", "year", ($year ? $year : date("Y")), $years). form_select("", "month", ($month ? $month : date("m")), $months) . form_select("", "day", ($day ? $day : date("d")), $days) . form_submit(t("Show"));
$start .= "</div>";
$output .= form($start);
/*
** Fetch nodes for the selected date, or current date if none
** selected.
*/
if ($year && $month && $day) {
$result = db_query_range("SELECT nid FROM {node} WHERE status = '1' AND created > %d AND created < %d ORDER BY created", $date, $date_end, 0, 20);
while ($nid = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $nid->nid)), 1);
}
}
print theme("page", $output);
}
function archive_settings() {
$output .= form_select(t("First day of week"), "default_firstday", variable_get("default_firstday", 0), array(0 => t("Sunday"), 1 => t("Monday"), 2 => t("Tuesday"), 3 => t("Wednesday"), 4 => t("Thursday"), 5 => t("Friday"), 6 => t("Saturday")), t("The first day of the week. By changing this value you choose how the calendar block is rendered."));
return $output;
}
?>
......@@ -10,16 +10,16 @@ function block_help($section = "admin/help#block") {
<p>Blocks are the boxes visible in the sidebar(s) of your web site. These are usually generated automatically by modules (e.g. recent forum topics), but you can also create your own blocks using either static HTML or dynamic PHP content.</p>
<p>The sidebar each block appears in depends on both which theme you're using (some are left-only, some right, some both), and on the settings in block management.</p><p>Whether a block is visible in the first place depends on four things:</p><ul><li>It must have its \"enabled\" box checked in block management.</li><li>If it has its \"custom\" box checked in block management, the user must have chosen to display it in their user preferences.</li><li>If the \"path\" field in block management is set, the visitor must be on a page that matches the path specification (more on this later).</li><li>If the block has its throttle box checked, the user will only see the block if the site throttle level is low.</li></ul>
<p>The block management screen also lets you specify the vertical sort-order of the blocks within a sidebar. You do this by assigning a <strong>weight</strong> to each block. Lighter blocks (smaller weight) \"float up\" towards the top of the sidebar. Heavier ones \"sink down\" towards the bottom of it. Once you've positioned things just so, you can preview what the layout will look like in different types of themes by clicking the preview placement link in the menu to the left.</p>
<p>The path setting lets you define the pages on which a specific block is visible. If you leave the path blank it will appear on all pages. The path uses a regular expression syntax so remember to escape special characters!</p>
<p>The path setting lets you define the pages on which a specific block is visible. If you leave the path blank it will appear on all pages. The path uses a regular expression syntax so remember to escape special characters! The path expression is matched against the relative URL of a Drupal page, e.g. <code>book</code>, <code>node/view/12</code>, <code>admin</code>.</p>
<p>In case you do not know what a regular expression is, you should read about them in the PHP manual. The chapter to look at is the one on <a href=\"%pcre\">Perl-Compatible Regular Expressions (PCRE)</a>.</p>
<p>However, for basic tasks it is sufficient to look at the following examples:</p>
<p>If the block should only show up on blog pages, use &lt;/blog&gt;. To display on all node views use &lt;/node/view&gt;. The angular brackets are used as delimiters of the regular expression. To show up on either forum or book pages use &lt;(/forum|/book)&gt;. The round brackets form a group of expressions, divided by the | character. It matches if any of the expressions in it match. A more complicated example is &lt;/node/add/(story|blog|image)&gt;. Blocks which have their paths set to this expression will show up on story, block, or image composition pages. If you want to show a block an all pages, but not the search page, use &lt;(^/\$|[^(search)\$/]+)&gt;</p>
<p>If the block should only show up on blog pages, use &lt;^blog&gt;. To display on all node views use &lt;^node/view&gt;. The angular brackets are used as delimiters of the regular expression. To show up on either forum or book pages use &lt;^(forum|book)&gt;. The round brackets form a group of expressions, divided by the | character. It matches if any of the expressions in it match. A more complicated example is &lt;^node/add/(story|blog|image)&gt;. Blocks which have their paths set to this expression will show up on story, block, or image composition pages. If you want to show a block an all pages, but not the search page, use &lt;^(?!search)&gt;.</p>
<h3>Administrator Defined Blocks</h3>
<p>An administrator defined block contains HTML, text or PHP content supplied by you (as opposed to being generated automatically by a module). Each admin-defined block consists of a title, a description, and a body containing text, HTML, or PHP code which can be as long as you wish. The Drupal engine will 'render' the content of the block.</p>
<h4>PHP in admin-defined blocks</h4>
<p>If you know how to script in PHP, Drupal gives you the power to embed any script you like inside a block. It will be executed when the page is viewed and dynamically embedded into the page. This gives you amazing flexibility and power, but of course with that comes danger and insecurity if you don't write good code. If you are not familiar with PHP, SQL or with the site engine, avoid experimenting with PHP blocks because you can corrupt your database or render your site insecure or even unusable! If you don't plan to do fancy stuff with your blocks then you're probably better off with straight HTML.</p>
<p>Remember that the code within each PHP block must be valid PHP code - including things like correctly terminating statements with a semicolon so that the parser won't die. It is highly recommended that you develop your blocks separately using a simple test script on top of a test database before migrating to your production environment.</p>
<p>Notes:</p><ul><li>You can use global variables, such as configuration parameters, within the scope of a PHP box but remember that variables which have been given values in a PHP box will retain these values in the engine or module afterwards.</li><li>register_globals is now set to <strong>off</strong> by default. If you need form information you need to get it from the \"superglobals\" \$_POST, \$_GET, etc.</li><li>You shuold use the <code>return</code> statement to return the actual content for your block.</li></ul>
<p>Notes:</p><ul><li>You can use global variables, such as configuration parameters, within the scope of a PHP box but remember that variables which have been given values in a PHP box will retain these values in the engine or module afterwards.</li><li>register_globals is now set to <strong>off</strong> by default. If you need form information you need to get it from the \"superglobals\" \$_POST, \$_GET, etc.</li><li>You should use the <code>return</code> statement to return the actual content for your block.</li></ul>
<p>A basic example:</p>
<blockquote><p>You want to have a box with the title \"Welcome\" that you use to greet your visitors. The content for this box could be created by going:</p>
<pre>
......@@ -40,7 +40,7 @@ function block_help($section = "admin/help#block") {
$output = t("Controls the boxes that are displayed around the main content.");
break;
case 'admin/system/block':
$output = t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the choosen theme. They are created by <strong>active</strong> Drupal modules. In order to view a block it must be enabled. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. The custom checkbox lets your users hide the block using their account setting. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the <a href=\"%createblock\">new block</a> link in the menu to the left. Edit and delete links will become active below for these admin-defined blocks. Blocks can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.", array("%createblock" => url("admin/system/block/add"), "%throttle" => url("admin/system/modules/throttle")));
$output = t("Blocks are the boxes in the left- and right- side bars of the web site, depending on the choosen theme. They are created by <strong>active</strong> Drupal modules. The 'enabled' checkbox sets the default status of the block. Only enabled blocks are shown. When the 'custom' checkbox is checked, your users can show or hide the block using their account settings. In that case, the 'enabled' checkbox signifies the block's default status. You can assign the block's placement by giving it a region and a weight. The region specifies which side of the page the block is on, and the weight sorts blocks within a region. Lighter (smaller weight value) blocks \"float up\" towards the top of the page. The path setting lets you define which pages you want a block to be shown on. You can also create your own blocks, where you specify the content of the block rather than its being generated by a module (you can even use PHP in these). You can create one of these by clicking the <a href=\"%createblock\">new block</a> link in the menu to the left. Edit and delete links will become active below for these admin-defined blocks. Blocks can automatically be temporarily disabled to reduce server load when your site becomes extremely busy by checking throttle. The auto-throttle functionality must be enabled on the <a href=\"%throttle\">throttle configuration page</a> after having enabled the throttle module.", array("%createblock" => url("admin/system/block/add"), "%throttle" => url("admin/system/modules/throttle")));
break;
case 'admin/system/block/add':
$output = t("Here you can create a new block. Once you have created this block you must make it active, and give it a place on the page using <a href=\"%overview\">blocks</a>. The title is used when displaying the block. The description is used in the \"block\" column on the <a href=\"%overview\">blocks</a> page. If you are going to place PHP code in the block, and you have <strong>create php content</strong> permission (see the <a href=\"%permission\">permissions</a> page) you <strong>must</strong> change the type to PHP to make your code active.", array("%overview" => url("admin/system/block"), "%permission" => url("admin/user/permission")));
......@@ -323,7 +323,7 @@ function block_user($type, $edit, &$user) {
while ($block = db_fetch_object($result)) {
$data = module_invoke($block->module, "block", "list");
if ($data[$block->delta]["info"]) {
$form .= form_checkbox($data[$block->delta]['info'], "block][$block->module][$block->delta", 1, $user->block[$block->module][$block->delta]);
$form .= form_checkbox($data[$block->delta]['info'], "block][$block->module][$block->delta", 1, isset($user->block[$block->module][$block->delta]) ? $user->block[$block->module][$block->delta] : $block->status);
}
}
......@@ -362,7 +362,11 @@ function block_list($region) {
$result = db_query("SELECT * FROM {blocks} WHERE (status = '1' OR custom = '1') ". ($region != "all" ? "AND region = %d " : "") ."ORDER BY weight, module", $region == "left" ? 0 : 1);
while ($result && ($block = db_fetch_array($result))) {
if ((($block['status'] && (!$user->uid || !$block['custom'])) || ($block['custom'] && $user->block[$block['module']][$block['delta']])) && (!$block['path'] || preg_match($block['path'], "/" . $_GET["q"]))) {
// When the user's account setting is empty, we use the block's regular 'status' (which is the default)
if ($block['custom'] && $user->uid && !isset($user->block[$block['module']][$block['delta']])) {
$user->block[$block['module']][$block['delta']] = $block['status'];
}
if ((($block['status'] && (!$user->uid || !$block['custom'])) || ($block['custom'] && $user->block[$block['module']][$block['delta']])) && (!$block['path'] || preg_match($block['path'], ereg_replace('^/(\?q=)?', '', request_uri())))) {
/*
** Check the current throttle status and see if block should be displayed
......
This diff is collapsed.
......@@ -12,7 +12,7 @@ function blog_node_name($node) {
}
function blog_perm() {
return array("maintain personal blog");
return array("edit own blog");
}
function blog_access($op, $node) {
......@@ -23,15 +23,15 @@ function blog_access($op, $node) {
}
if ($op == "create") {
return user_access("maintain personal blog") && $user->uid;
return user_access("edit own blog") && $user->uid;
}
if ($op == "update") {
return user_access("maintain personal blog") && ($user->uid == $node->uid);
return user_access("edit own blog") && ($user->uid == $node->uid);
}
if ($op == "delete") {
return user_access("maintain personal blog") && ($user->uid == $node->uid);
return user_access("edit own blog") && ($user->uid == $node->uid);
}
}
......@@ -40,7 +40,7 @@ function blog_user($type, &$edit, &$user) {
switch ($type) {
case "view_public":
case "view_private":
if (user_access("maintain personal blog", $user)) {
if (user_access("edit own blog", $user)) {
return form_item(t("Blog"), l(t("view recent blog entries"), "blog/$user->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $user->name)))));
}
}
......@@ -86,7 +86,7 @@ function blog_feed_user($uid = 0) {
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15);
$channel["title"] = $account->name ."'s blog";
$channel["link"] = url("blog/view/$uid");
$channel["link"] = url("blog/$uid", NULL, NULL, TRUE);
$channel["description"] = $term->description;
node_feed($result, $channel);
}
......@@ -221,7 +221,7 @@ function blog_link($type, $node = 0, $main) {
$links = array();
if ($type == "system") {
if (user_access("maintain personal blog")) {
if (user_access("edit own blog")) {
menu("node/add/blog", t("blog entry"), "node_page", 0);
menu("blog/". $user->uid, t("my blog"), "blog_page", 1);
}
......
<?php
// $Id$
function blog_settings() {
$output = form_textarea(t("Explanation or submission guidelines"), "blog_help", variable_get("blog_help", ""), 70, 4, t("This text is displayed at the top of the blog submission form. It's useful for helping or instructing your users."));
$output .= form_select(t("Minimum number of words in a blog entry"), "minimum_blog_size", variable_get("minimum_blog_size", 0), drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), t("The minimum number of words a personal blog entry should contain. This is useful to rule out submissions that do not meet the site's standards, such as short test posts."));
return $output;
}
function blog_node_name($node) {
return t("personal blog entry");
}
function blog_perm() {
return array("maintain personal blog");
}
function blog_access($op, $node) {
global $user;
if ($op == "view") {
return $node->status;
}
if ($op == "create") {
return user_access("maintain personal blog") && $user->uid;
}
if ($op == "update") {
return user_access("maintain personal blog") && ($user->uid == $node->uid);
}
if ($op == "delete") {
return user_access("maintain personal blog") && ($user->uid == $node->uid);
}
}
function blog_user($type, &$edit, &$user) {
switch ($type) {
case "view_public":
case "view_private":
if (user_access("maintain personal blog", $user)) {
return form_item(t("Blog"), l(t("view recent blog entries"), "blog/$user->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $user->name)))));
}
}
}
function blog_help($section) {
$output ="";
switch ($section) {
case 'admin/help#blog':
$output .= t("
<p>Drupal's blog module allows registered users to maintain an online weblog (commonly known as a blog), often referred to as an online journal or diary. These can be filled with daily thoughts, poetry, boneless blabber, spiritual theories, intimate details, valuable experiences, cynical rants, semi-coherent comments, writing experiments, artistic babblings, critics on current facts, fresh insights, diverse dreams, chronicles and mumbling madness available for public consumption.</p>
<p>Blogs are made up of individual entries (nodes) that are timestamped and are typically viewed by day as you would a diary. Blogs often contain links to things you've seen and/or agree/disagree with. A typical example of a long term blog can be seen at %scripting-com.</p>
<p>The blog module adds a \"user blogs\" navigation link to the site, which takes any visitor to a page that displays the most recent blog entries from all the users on the site. Personal user menus gain a \"create a blog entry\" link (which takes you to a submission form) and a \"view personal blog\" link (which displays your blog entries as other people will see them). On the bottom of each of your own blog entries, there is an \"edit this blog entry\" link that lets you edit or delete that entry.</p>
<p>If a user has the ability to post blogs, then the import module (news aggregator) will display a blog-it link <strong>(b)</strong> next to each news item in its lists. Click on this and you will be taken to the blog submission form, with the title, a link to the item, and a link to the source into the body text already in the text box, ready for you to add your explanation. This actively encourages people to add blog entries about things they see and hear elsewhere in the Drupal site and from your syndicated partner sites.</p>", array("%scripting-com" => "<a href=\"http://www.scripting.com/\">http://www.scripting.com/</a>"));
break;
case 'admin/system/modules#description':
$output .= t("Enables keeping a blog or easily and regularly updated web page.");
break;
case 'admin/system/modules/blog':
$output .= t("A weblog is a running journal of a user's ideas. Enter the minimum word count for a single entry, and the text displayed on the entry submission form");
break;
case 'node/add/blog':
$output = variable_get('blog_help', '');
break;
case 'node/add#blog':
$output = t("A blog is a regularly updated journal made up of individual entries, often called posts, that are time stamped and typically arranged by the day, with the newest on top (a diary is the reverse). They tend to be quite personal, often containing links to things you've seen, or to editorials that you find interesting. Some blogs also contain original material written solely for the blog. Since a Blog is personal, you and only you have full control over what you publish. The most interesting blog entries or those blog entries that fit the site's topic well might get promoted to the front page by the community or by users with the access do this.");
break;
}
return $output;
}
function blog_feed_user($uid = 0) {
global $user;
if ($uid) {
$account = user_load(array("uid" => $uid, "status" => 1));
}
else {
$account = $user;
}
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15);
$channel["title"] = $account->name ."'s blog";
$channel["link"] = url("blog/view/$uid");
$channel["description"] = $term->description;
node_feed($result, $channel);
}
function blog_feed_last() {
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 15);
$channel["title"] = variable_get("site_name", "drupal") ." blogs";
$channel["link"] = url("blog");
$channel["description"] = $term->description;
node_feed($result, $channel);
}
function blog_page_user($uid) {
$account = user_load(array((is_numeric($uid) ? "uid" : "name") => $uid, "status" => 1));
$title = t("%name's blog", array("%name" => $account->name));
$output = "";
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND uid = '$account->uid' AND status = 1 ORDER BY nid DESC", variable_get("default_nodes_main", 10));
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $node->nid)), 1);
}
$output .= theme('pager', NULL, variable_get("default_nodes_main", 10));
$output .= theme('xml_icon', url("blog/feed/$account->uid"));
drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. $title .'" href="'. url("blog/feed/$account->uid") .'" />');
print theme("page", $output, $title);
}
function blog_page_last() {
global $user;
$output = "";
$result = pager_query("SELECT nid FROM {node} WHERE type = 'blog' AND status = 1 ORDER BY nid DESC", variable_get("default_nodes_main", 10));
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $node->nid)), 1);
}
$output .= theme('pager', NULL, variable_get("default_nodes_main", 10));
$output .= theme('xml_icon', url('blog/feed'));
drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - blogs" href="'. url('blog/feed') .'" />');
print theme("page", $output);
}
function blog_validate(&$node) {
/*
** Validate the size of the blog:
*/
if (isset($node->body) && count(explode(" ", $node->body)) < variable_get("minimum_blog_size", 0)) {
$error["body"] = theme("error", t("The body of your blog is too short."));
}
return $error;
}
function blog_form(&$node, &$error) {
global $nid;
$iid = $_GET["iid"];
if (empty($node->body)) {
/*
** If the user clicked a "blog it" link, we load the data from the
** database and quote it in the blog:
*/
if ($nid && $blog = node_load(array("nid" => $nid))) {
$node->body = "<i>". $blog->body ."</i> [". l($blog->name, "node/view/$nid") ."]";
}
if ($iid && $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM {item} i, {feed} f WHERE i.iid = %d AND i.fid = f.fid", $iid))) {
$node->title = $item->title;
$node->body = "<a href=\"$item->link\">$item->title</a> - <i>". check_output($item->description) ."</i> [<a href=\"$item->flink\">$item->ftitle</a>]\n";
}
}
if (function_exists("taxonomy_node_form")) {
$output .= implode("", taxonomy_node_form("blog", $node));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : filter_tips_short());
return $output;
}
function blog_page() {
switch (arg(1)) {
case "feed":
if (arg(2)) {
blog_feed_user(arg(2));
}
else {
blog_feed_last();
}
break;
default:
if (arg(1)) {
blog_page_user(arg(1));
}
else {
blog_page_last();
}
}
}
function blog_content($node, $main = 0) {
return node_prepare($node, $main);
}
function blog_view($node, $main = 0, $page = 0) {
if ($page) {
// Breadcrumb navigation
$breadcrumb[] = l(t("Home"), "");
$breadcrumb[] = l(t("blogs"), "blog");
$breadcrumb[] = l(t("%name's blog", array("%name" => $node->name)), "blog/$node->uid");
// set the breadcrumb
drupal_set_breadcrumb($breadcrumb);
}
// prepare the node content
$node = blog_content($node, $main);
// print the node
return theme("node", $node, $main, $page);
}
function blog_link($type, $node = 0, $main) {
global $user;
$links = array();
if ($type == "system") {
if (user_access("maintain personal blog")) {
menu("node/add/blog", t("blog entry"), "node_page", 0);
menu("blog/". $user->uid, t("my blog"), "blog_page", 1);
}
if (user_access("access content")) {
menu("blog", t("blogs"), "blog_page", 0, MENU_HIDE);
}
}
if ($type == "page" && user_access("access content")) {
$links[] = l(t("blogs"), "blog", array("title" => t("Read the latest blog entries.")));
}
if ($type == "node" && $node->type == "blog") {
if (blog_access("update", $node)) {
$links[] = l(t("edit this blog entry"), "node/edit/$node->nid", array("title" => t("Edit this blog entry.")));
}
elseif (arg(0) != 'blog' && arg(1) != $node->uid) {
$links[] = l(t("%username's blog", array("%username" => $node->name)), "blog/$node->uid", array("title" => t("Read %username's latest blog entries.", array("%username" => $node->name))));
}
}
return $links;
}
function blog_block($op = "list", $delta = 0) {
global $user;
if ($op == "list") {
$block[0]["info"] = t("Blogs");
return $block;
}
else {
if (user_access("access content")) {
$block["content"] = node_title_list(db_query_range("SELECT n.title, n.nid FROM {node} n WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.nid DESC", 0, 10));
$block["content"] .= "<div class=\"more-link\">". l(t("more"), "blog", array("title" => t("Read the latest blog entries."))) ."</div>";
$block["subject"] = t("Blogs");
}
return $block;
}
}
?>