Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
bbca6b48
Commit
bbca6b48
authored
19 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#52418
by Zen: fapi conversion + bug fixes.
parent
6d9e5084
No related branches found
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
misc/drupal.css
+3
-0
3 additions, 0 deletions
misc/drupal.css
modules/archive.module
+86
-69
86 additions, 69 deletions
modules/archive.module
modules/archive/archive.module
+86
-69
86 additions, 69 deletions
modules/archive/archive.module
with
175 additions
and
138 deletions
misc/drupal.css
+
3
−
0
View file @
bbca6b48
...
@@ -247,6 +247,9 @@ tr.odd .form-item, tr.even .form-item {
...
@@ -247,6 +247,9 @@ tr.odd .form-item, tr.even .form-item {
.book-navigation
.page-next
{
.book-navigation
.page-next
{
text-align
:
left
;
text-align
:
left
;
}
}
.archive
{
margin
:
1em
0
1em
0
;
}
.calendar
.row-week
td
a
{
.calendar
.row-week
td
a
{
display
:
block
;
display
:
block
;
}
}
...
...
This diff is collapsed.
Click to expand it.
modules/archive.module
+
86
−
69
View file @
bbca6b48
...
@@ -27,26 +27,52 @@ function archive_help($section) {
...
@@ -27,26 +27,52 @@ function archive_help($section) {
}
}
}
}
/**
* Implementation of hook_menu().
*/
function
archive_menu
(
$may_cache
)
{
$items
=
array
();
if
(
$may_cache
)
{
$items
[]
=
array
(
'path'
=>
'archive'
,
'title'
=>
t
(
'archives'
),
'access'
=>
user_access
(
'access content'
),
'callback'
=>
'archive_page'
,
'type'
=>
MENU_SUGGESTED_ITEM
);
}
return
$items
;
}
/**
* Implementation of hook_block().
*
* Generates a calendar for the current month, with links to the archives
* for each day.
*/
function
archive_block
(
$op
=
'list'
,
$delta
=
0
)
{
if
(
$op
==
'list'
)
{
$blocks
[
0
][
'info'
]
=
t
(
'Calendar to browse archives'
);
return
$blocks
;
}
else
if
(
$op
==
'view'
&&
user_access
(
'access content'
))
{
$block
[
'subject'
]
=
t
(
'Browse archives'
);
$block
[
'content'
]
=
archive_calendar
();
return
$block
;
}
}
/**
/**
* Generates a monthly calendar, for display in the archive block.
* Generates a monthly calendar, for display in the archive block.
*/
*/
function
archive_calendar
(
$original
=
0
)
{
function
archive_calendar
()
{
global
$user
;
global
$user
;
$edit
=
$_POST
[
'edit'
];
// Extract today's date:
// Extract today's date:
$start_of_today
=
mktime
(
0
,
0
,
0
,
date
(
'n'
,
time
()),
date
(
'd'
,
time
()),
date
(
'Y'
,
time
()))
+
$user
->
timezone
;
$start_of_today
=
mktime
(
0
,
0
,
0
,
date
(
'n'
,
time
()),
date
(
'd'
,
time
()),
date
(
'Y'
,
time
()))
+
$user
->
timezone
;
$end_of_today
=
mktime
(
23
,
59
,
59
,
date
(
'n'
,
time
()),
date
(
'd'
,
time
()),
date
(
'Y'
,
time
()))
+
$user
->
timezone
;
$end_of_today
=
mktime
(
23
,
59
,
59
,
date
(
'n'
,
time
()),
date
(
'd'
,
time
()),
date
(
'Y'
,
time
()))
+
$user
->
timezone
;
// Extract the requested date:
// Extract the requested date:
if
(
$edit
[
'year'
]
&&
$edit
[
'month'
]
&&
$edit
[
'day'
])
{
if
(
arg
(
0
)
==
'archive'
&&
arg
(
3
))
{
$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
);
$year
=
arg
(
1
);
$month
=
arg
(
2
);
$month
=
arg
(
2
);
$day
=
arg
(
3
);
$day
=
arg
(
3
);
...
@@ -188,87 +214,78 @@ function archive_calendar($original = 0) {
...
@@ -188,87 +214,78 @@ function archive_calendar($original = 0) {
return
$output
;
return
$output
;
}
}
/**
* Implementation of hook_block().
*
* Generates a calendar for the current month, with links to the archives
* for each day.
*/
function
archive_block
(
$op
=
'list'
,
$delta
=
0
)
{
if
(
$op
==
'list'
)
{
$blocks
[
0
][
'info'
]
=
t
(
'Calendar to browse archives'
);
return
$blocks
;
}
else
if
(
$op
==
'view'
&&
user_access
(
'access content'
))
{
$block
[
'subject'
]
=
t
(
'Browse archives'
);
$block
[
'content'
]
=
archive_calendar
();
return
$block
;
}
}
/**
* Implementation of hook_menu().
*/
function
archive_menu
(
$may_cache
)
{
$items
=
array
();
if
(
$may_cache
)
{
$items
[]
=
array
(
'path'
=>
'archive'
,
'title'
=>
t
(
'archives'
),
'access'
=>
user_access
(
'access content'
),
'callback'
=>
'archive_page'
,
'type'
=>
MENU_SUGGESTED_ITEM
);
}
return
$items
;
}
/**
/**
* Menu callback; lists all nodes posted on a given date.
* Menu callback; lists all nodes posted on a given date.
*/
*/
function
archive_page
(
$year
=
0
,
$month
=
0
,
$day
=
0
)
{
function
archive_page
(
$year
=
0
,
$month
=
0
,
$day
=
0
)
{
global
$user
;
global
$user
;
$op
=
$_POST
[
'op'
];
$edit
=
$_POST
[
'edit'
];
if
(
$op
==
t
(
'Show'
))
{
$year
=
$edit
[
'year'
];
$month
=
$edit
[
'month'
];
$day
=
$edit
[
'day'
];
}
$date
=
mktime
(
0
,
0
,
0
,
$month
,
$day
,
$year
)
-
$user
->
timezone
;
$date
=
mktime
(
0
,
0
,
0
,
$month
,
$day
,
$year
)
-
$user
->
timezone
;
$date_end
=
mktime
(
0
,
0
,
0
,
$month
,
$day
+
1
,
$year
)
-
$user
->
timezone
;
$date_end
=
mktime
(
0
,
0
,
0
,
$month
,
$day
+
1
,
$year
)
-
$user
->
timezone
;
// Prepare the values of the form fields.
// Display form.
$years
=
drupal_map_assoc
(
range
(
2000
,
2010
));
$output
=
archive_browse_form
(
$year
,
$month
,
$day
);
$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
));
$form
[
'year'
]
=
array
(
'#type'
=>
'select'
,
'#default_value'
=>
(
$year
?
$year
:
date
(
'Y'
)),
'#options'
=>
$years
);
$form
[
'month'
]
=
array
(
'#type'
=>
'select'
,
'#default_value'
=>
(
$month
?
$month
:
date
(
'm'
)),
'#options'
=>
$months
);
$form
[
'day'
]
=
array
(
'#type'
=>
'select'
,
'#default_value'
=>
(
$day
?
$day
:
date
(
'd'
)),
'#options'
=>
$days
);
$form
[
'show'
]
=
array
(
'#type'
=>
'submit'
,
'#value'
=>
t
(
'Show'
));
$output
=
drupal_get_form
(
'archive_dates'
,
$form
);
if
(
$year
&&
$month
&&
$day
)
{
if
(
$year
&&
$month
&&
$day
)
{
// Fetch nodes for the selected date, if one was specified.
// Fetch nodes for the selected date, if one was specified.
$sql
=
'SELECT n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.created > %d AND n.created < %d ORDER BY n.created'
;
$sql
=
'SELECT n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.created > %d AND n.created < %d ORDER BY n.created'
;
$sql
=
db_rewrite_sql
(
$sql
);
$sql
=
db_rewrite_sql
(
$sql
);
$result
=
db_query_range
(
$sql
,
$date
,
$date_end
,
0
,
20
);
$result
=
db_query_range
(
$sql
,
$date
,
$date_end
,
0
,
20
);
if
(
db_num_rows
(
$result
)
>
0
)
{
while
(
$nid
=
db_fetch_object
(
$result
))
{
while
(
$nid
=
db_fetch_object
(
$result
))
{
$output
.
=
node_view
(
node_load
(
$nid
->
nid
),
1
);
$output
.
=
node_view
(
node_load
(
$nid
->
nid
),
1
);
}
}
}
else
{
$output
.
=
theme
(
'box'
,
t
(
'No posts found.'
),
''
);
}
}
else
{
$output
.
=
theme
(
'box'
,
t
(
'No posts found.'
),
''
);
}
}
return
$output
;
return
$output
;
}
}
/**
* Generate a form that retrieves archives for a certain date.
*/
function
archive_browse_form
(
$year
,
$month
,
$day
)
{
// Prepare the values of the form fields.
$years
=
drupal_map_assoc
(
range
(
2000
,
2010
));
$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
(
1
,
31
));
$form
[
'year'
]
=
array
(
'#type'
=>
'select'
,
'#default_value'
=>
(
$year
?
$year
:
date
(
'Y'
)),
'#options'
=>
$years
,
);
$form
[
'month'
]
=
array
(
'#type'
=>
'select'
,
'#default_value'
=>
(
$month
?
$month
:
date
(
'm'
)),
'#options'
=>
$months
,
);
$form
[
'day'
]
=
array
(
'#type'
=>
'select'
,
'#default_value'
=>
(
$day
?
$day
:
date
(
'd'
)),
'#options'
=>
$days
,
);
$form
[
'show'
]
=
array
(
'#type'
=>
'submit'
,
'#value'
=>
t
(
'Show'
),
);
return
drupal_get_form
(
'archive_browse_form'
,
$form
);
}
/**
* Process archive browse form submission.
*/
function
archive_browse_form_submit
(
$form_id
,
$form_values
)
{
return
(
'archive/'
.
$form_values
[
'year'
]
.
'/'
.
$form_values
[
'month'
]
.
'/'
.
$form_values
[
'day'
]);
}
/**
/**
* Form theme function; displays the archive date navigation form inline.
* Form theme function; displays the archive date navigation form inline.
*/
*/
function
theme_archive_
dates
(
$form
)
{
function
theme_archive_
browse_form
(
$form
)
{
$output
=
'<div class="container-inline">'
.
form_render
(
$form
)
.
'</div>'
;
$output
=
'<div class="container-inline
archive
">'
.
form_render
(
$form
)
.
'</div>'
;
return
$output
;
return
$output
;
}
}
This diff is collapsed.
Click to expand it.
modules/archive/archive.module
+
86
−
69
View file @
bbca6b48
...
@@ -27,26 +27,52 @@ function archive_help($section) {
...
@@ -27,26 +27,52 @@ function archive_help($section) {
}
}
}
}
/**
* Implementation of hook_menu().
*/
function
archive_menu
(
$may_cache
)
{
$items
=
array
();
if
(
$may_cache
)
{
$items
[]
=
array
(
'path'
=>
'archive'
,
'title'
=>
t
(
'archives'
),
'access'
=>
user_access
(
'access content'
),
'callback'
=>
'archive_page'
,
'type'
=>
MENU_SUGGESTED_ITEM
);
}
return
$items
;
}
/**
* Implementation of hook_block().
*
* Generates a calendar for the current month, with links to the archives
* for each day.
*/
function
archive_block
(
$op
=
'list'
,
$delta
=
0
)
{
if
(
$op
==
'list'
)
{
$blocks
[
0
][
'info'
]
=
t
(
'Calendar to browse archives'
);
return
$blocks
;
}
else
if
(
$op
==
'view'
&&
user_access
(
'access content'
))
{
$block
[
'subject'
]
=
t
(
'Browse archives'
);
$block
[
'content'
]
=
archive_calendar
();
return
$block
;
}
}
/**
/**
* Generates a monthly calendar, for display in the archive block.
* Generates a monthly calendar, for display in the archive block.
*/
*/
function
archive_calendar
(
$original
=
0
)
{
function
archive_calendar
()
{
global
$user
;
global
$user
;
$edit
=
$_POST
[
'edit'
];
// Extract today's date:
// Extract today's date:
$start_of_today
=
mktime
(
0
,
0
,
0
,
date
(
'n'
,
time
()),
date
(
'd'
,
time
()),
date
(
'Y'
,
time
()))
+
$user
->
timezone
;
$start_of_today
=
mktime
(
0
,
0
,
0
,
date
(
'n'
,
time
()),
date
(
'd'
,
time
()),
date
(
'Y'
,
time
()))
+
$user
->
timezone
;
$end_of_today
=
mktime
(
23
,
59
,
59
,
date
(
'n'
,
time
()),
date
(
'd'
,
time
()),
date
(
'Y'
,
time
()))
+
$user
->
timezone
;
$end_of_today
=
mktime
(
23
,
59
,
59
,
date
(
'n'
,
time
()),
date
(
'd'
,
time
()),
date
(
'Y'
,
time
()))
+
$user
->
timezone
;
// Extract the requested date:
// Extract the requested date:
if
(
$edit
[
'year'
]
&&
$edit
[
'month'
]
&&
$edit
[
'day'
])
{
if
(
arg
(
0
)
==
'archive'
&&
arg
(
3
))
{
$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
);
$year
=
arg
(
1
);
$month
=
arg
(
2
);
$month
=
arg
(
2
);
$day
=
arg
(
3
);
$day
=
arg
(
3
);
...
@@ -188,87 +214,78 @@ function archive_calendar($original = 0) {
...
@@ -188,87 +214,78 @@ function archive_calendar($original = 0) {
return
$output
;
return
$output
;
}
}
/**
* Implementation of hook_block().
*
* Generates a calendar for the current month, with links to the archives
* for each day.
*/
function
archive_block
(
$op
=
'list'
,
$delta
=
0
)
{
if
(
$op
==
'list'
)
{
$blocks
[
0
][
'info'
]
=
t
(
'Calendar to browse archives'
);
return
$blocks
;
}
else
if
(
$op
==
'view'
&&
user_access
(
'access content'
))
{
$block
[
'subject'
]
=
t
(
'Browse archives'
);
$block
[
'content'
]
=
archive_calendar
();
return
$block
;
}
}
/**
* Implementation of hook_menu().
*/
function
archive_menu
(
$may_cache
)
{
$items
=
array
();
if
(
$may_cache
)
{
$items
[]
=
array
(
'path'
=>
'archive'
,
'title'
=>
t
(
'archives'
),
'access'
=>
user_access
(
'access content'
),
'callback'
=>
'archive_page'
,
'type'
=>
MENU_SUGGESTED_ITEM
);
}
return
$items
;
}
/**
/**
* Menu callback; lists all nodes posted on a given date.
* Menu callback; lists all nodes posted on a given date.
*/
*/
function
archive_page
(
$year
=
0
,
$month
=
0
,
$day
=
0
)
{
function
archive_page
(
$year
=
0
,
$month
=
0
,
$day
=
0
)
{
global
$user
;
global
$user
;
$op
=
$_POST
[
'op'
];
$edit
=
$_POST
[
'edit'
];
if
(
$op
==
t
(
'Show'
))
{
$year
=
$edit
[
'year'
];
$month
=
$edit
[
'month'
];
$day
=
$edit
[
'day'
];
}
$date
=
mktime
(
0
,
0
,
0
,
$month
,
$day
,
$year
)
-
$user
->
timezone
;
$date
=
mktime
(
0
,
0
,
0
,
$month
,
$day
,
$year
)
-
$user
->
timezone
;
$date_end
=
mktime
(
0
,
0
,
0
,
$month
,
$day
+
1
,
$year
)
-
$user
->
timezone
;
$date_end
=
mktime
(
0
,
0
,
0
,
$month
,
$day
+
1
,
$year
)
-
$user
->
timezone
;
// Prepare the values of the form fields.
// Display form.
$years
=
drupal_map_assoc
(
range
(
2000
,
2010
));
$output
=
archive_browse_form
(
$year
,
$month
,
$day
);
$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
));
$form
[
'year'
]
=
array
(
'#type'
=>
'select'
,
'#default_value'
=>
(
$year
?
$year
:
date
(
'Y'
)),
'#options'
=>
$years
);
$form
[
'month'
]
=
array
(
'#type'
=>
'select'
,
'#default_value'
=>
(
$month
?
$month
:
date
(
'm'
)),
'#options'
=>
$months
);
$form
[
'day'
]
=
array
(
'#type'
=>
'select'
,
'#default_value'
=>
(
$day
?
$day
:
date
(
'd'
)),
'#options'
=>
$days
);
$form
[
'show'
]
=
array
(
'#type'
=>
'submit'
,
'#value'
=>
t
(
'Show'
));
$output
=
drupal_get_form
(
'archive_dates'
,
$form
);
if
(
$year
&&
$month
&&
$day
)
{
if
(
$year
&&
$month
&&
$day
)
{
// Fetch nodes for the selected date, if one was specified.
// Fetch nodes for the selected date, if one was specified.
$sql
=
'SELECT n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.created > %d AND n.created < %d ORDER BY n.created'
;
$sql
=
'SELECT n.nid, n.created FROM {node} n WHERE n.status = 1 AND n.created > %d AND n.created < %d ORDER BY n.created'
;
$sql
=
db_rewrite_sql
(
$sql
);
$sql
=
db_rewrite_sql
(
$sql
);
$result
=
db_query_range
(
$sql
,
$date
,
$date_end
,
0
,
20
);
$result
=
db_query_range
(
$sql
,
$date
,
$date_end
,
0
,
20
);
if
(
db_num_rows
(
$result
)
>
0
)
{
while
(
$nid
=
db_fetch_object
(
$result
))
{
while
(
$nid
=
db_fetch_object
(
$result
))
{
$output
.
=
node_view
(
node_load
(
$nid
->
nid
),
1
);
$output
.
=
node_view
(
node_load
(
$nid
->
nid
),
1
);
}
}
}
else
{
$output
.
=
theme
(
'box'
,
t
(
'No posts found.'
),
''
);
}
}
else
{
$output
.
=
theme
(
'box'
,
t
(
'No posts found.'
),
''
);
}
}
return
$output
;
return
$output
;
}
}
/**
* Generate a form that retrieves archives for a certain date.
*/
function
archive_browse_form
(
$year
,
$month
,
$day
)
{
// Prepare the values of the form fields.
$years
=
drupal_map_assoc
(
range
(
2000
,
2010
));
$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
(
1
,
31
));
$form
[
'year'
]
=
array
(
'#type'
=>
'select'
,
'#default_value'
=>
(
$year
?
$year
:
date
(
'Y'
)),
'#options'
=>
$years
,
);
$form
[
'month'
]
=
array
(
'#type'
=>
'select'
,
'#default_value'
=>
(
$month
?
$month
:
date
(
'm'
)),
'#options'
=>
$months
,
);
$form
[
'day'
]
=
array
(
'#type'
=>
'select'
,
'#default_value'
=>
(
$day
?
$day
:
date
(
'd'
)),
'#options'
=>
$days
,
);
$form
[
'show'
]
=
array
(
'#type'
=>
'submit'
,
'#value'
=>
t
(
'Show'
),
);
return
drupal_get_form
(
'archive_browse_form'
,
$form
);
}
/**
* Process archive browse form submission.
*/
function
archive_browse_form_submit
(
$form_id
,
$form_values
)
{
return
(
'archive/'
.
$form_values
[
'year'
]
.
'/'
.
$form_values
[
'month'
]
.
'/'
.
$form_values
[
'day'
]);
}
/**
/**
* Form theme function; displays the archive date navigation form inline.
* Form theme function; displays the archive date navigation form inline.
*/
*/
function
theme_archive_
dates
(
$form
)
{
function
theme_archive_
browse_form
(
$form
)
{
$output
=
'<div class="container-inline">'
.
form_render
(
$form
)
.
'</div>'
;
$output
=
'<div class="container-inline
archive
">'
.
form_render
(
$form
)
.
'</div>'
;
return
$output
;
return
$output
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment