FINAL suepr merge step : added all modules to this super repos
This commit is contained in:
@@ -0,0 +1,372 @@
|
||||
body form#page-manager-list-pages-form {
|
||||
margin: 0 0 20px 0;
|
||||
}
|
||||
|
||||
#page-manager-list-pages-form .form-item {
|
||||
padding-right: 1em; /* LTR */
|
||||
float: left; /* LTR */
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#page-manager-list-pages {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#edit-order-wrapper {
|
||||
clear: left; /* LTR */
|
||||
}
|
||||
|
||||
#edit-pages-apply,
|
||||
#edit-pages-reset {
|
||||
margin-top: 1.65em;
|
||||
float: left; /* LTR */
|
||||
}
|
||||
|
||||
#page-manager-edit {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
#page-manager-edit table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#page-manager-edit table tr.even {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
#page-manager-list-pages tr.page-manager-disabled td {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
#page-manager-list-pages tr.page-manager-locked td.page-manager-page-name {
|
||||
font-style: italic;
|
||||
color: green;
|
||||
padding-left: 22px; /* LTR */
|
||||
background: url(../images/locked.png) no-repeat scroll left center; /* LTR */
|
||||
}
|
||||
|
||||
#page-manager-list-pages tr.page-manager-locked-other td.page-manager-page-name {
|
||||
font-style: italic;
|
||||
color: red;
|
||||
padding-left: 22px; /* LTR */
|
||||
background: url(../images/locked-other.png) no-repeat scroll left center; /* LTR */
|
||||
}
|
||||
|
||||
/* Force the background color to inherit so that the dropbuttons do not need
|
||||
a specific background color. */
|
||||
#page-manager-list-pages td.page-manager-page-operations {
|
||||
vertical-align: top;
|
||||
position: relative;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#page-manager-list-pages td.page-manager-page-operations .ctools-dropbutton {
|
||||
text-align: left; /* LTR */
|
||||
}
|
||||
|
||||
|
||||
|
||||
#page-manager-edit .page-manager-wrapper {
|
||||
margin: 0;
|
||||
padding: 0 0 0 149px;
|
||||
color: #494949;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-tabs {
|
||||
border: 1px solid #aaa;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations {
|
||||
float: left; /* LTR */
|
||||
width: 150px;
|
||||
margin-left: -150px;
|
||||
margin-top: -1px;
|
||||
height: 100%;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations .inside {
|
||||
border-top: 1px solid #aaa;
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations ul {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
padding: 0;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations li {
|
||||
list-style: none;
|
||||
background: #F6F6F6;
|
||||
border-top: 1px solid #aaa;
|
||||
border-left: 1px solid #aaa;
|
||||
border-right: 1px solid #aaa;
|
||||
padding: 0 0 0 0;
|
||||
margin: 0;
|
||||
line-height: 2em;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations li.active,
|
||||
#page-manager-edit .page-manager-edit-operations li.active-group .page-manager-group-title {
|
||||
background: #FFFFFF url(../images/arrow-active.png) no-repeat scroll right center;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations li.changed,
|
||||
#page-manager-edit .page-manager-edit-operations li.changed-group .page-manager-group-title {
|
||||
background-color: #ffe;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/** provide a reset for non active stray paths */
|
||||
#page-manager-edit .page-manager-edit-operations li.active-group li.not-active .page-manager-group-title,
|
||||
#page-manager-edit .page-manager-edit-operations li.changed-group li.not-changed .page-manager-group-title {
|
||||
background: #F6F6F6;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations li.active {
|
||||
border-right: 1px solid white;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations li.active a,
|
||||
#page-manager-edit .page-manager-edit-operations li.active a:hover {
|
||||
background: #FFFFFF url(../images/arrow-active.png) no-repeat scroll right center;
|
||||
color: #000000;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations li.operation-first {
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations li li.operation-first {
|
||||
border-top: 1px solid #aaa;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations li a {
|
||||
display: block;
|
||||
padding: 0 0 0 .5em;
|
||||
color: #494949;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations li a:hover {
|
||||
background-color: #eee;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#page-manager-edit .ctools-collapsible-container {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
*float: left; /* LTR */
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations li .ctools-collapsible-handle:hover {
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations li li {
|
||||
border-right: none;
|
||||
border-left: none;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-edit-operations li ul {
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-group-title {
|
||||
line-height: 2em;
|
||||
font-weight: bold;
|
||||
padding: 0 0 0 .5em;
|
||||
}
|
||||
|
||||
/* Change the position of the arrow on the dropdown to look nicer with our defaults. */
|
||||
#page-manager-edit .page-manager-edit-operations .ctools-toggle {
|
||||
background-position: 0 9px;
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-ajax-pad {
|
||||
float: left; /* LTR */
|
||||
width: 100%;
|
||||
border-left: none;
|
||||
height: 100%;
|
||||
background: white;
|
||||
}
|
||||
|
||||
/** A riser to force the ajax pad to a minimum height. **/
|
||||
#page-manager-edit .page-manager-ajax-pad .page-manager-riser {
|
||||
width: 1px;
|
||||
float: right; /* LTR */
|
||||
height: 400px;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-ajax-pad .page-manager-riser span {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-ajax-pad .content-title {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
background-color: #fafafa;
|
||||
border-bottom: 1px solid #aaa;
|
||||
border-left: 1px solid #aaa;
|
||||
margin-left: -1px;
|
||||
padding: 2px 5px 2px 20px;
|
||||
}
|
||||
|
||||
#page-manager-edit .actions {
|
||||
padding: 0 0 0 20px;
|
||||
}
|
||||
|
||||
#page-manager-edit .primary-actions li {
|
||||
border-top: 1px solid #aaa;
|
||||
}
|
||||
|
||||
#page-manager-edit .secondary-actions {
|
||||
border-bottom: 1px solid #aaa;
|
||||
}
|
||||
|
||||
#page-manager-edit .handler-actions {
|
||||
float: right; /* LTR */
|
||||
}
|
||||
|
||||
#page-manager-edit .actions .page-manager-group-title {
|
||||
float: left; /* LTR */
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
#page-manager-edit .actions ul {
|
||||
float: right; /* LTR */
|
||||
text-align: right; /* LTR */
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border-right: 1px solid #aaa;
|
||||
}
|
||||
|
||||
#page-manager-edit .handler-title .actions ul {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
#page-manager-edit .actions li {
|
||||
float: left; /* LTR */
|
||||
background: none;
|
||||
list-style: none;
|
||||
border-left: 1px solid #aaa;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#page-manager-edit .actions ul li.operation-last {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
#page-manager-edit .actions li a:hover {
|
||||
background-color: #eee;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#page-manager-edit .actions li a {
|
||||
display: block;
|
||||
padding: 0.2em 0.5em;
|
||||
color:#0062A0;
|
||||
background-color: #F6F6F6;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-changed {
|
||||
float: right; /* LTR */
|
||||
font-style: italic;
|
||||
color: #f93;
|
||||
padding-left: 1em;
|
||||
padding-right: 22px;
|
||||
background: url(../images/locked.png) no-repeat scroll right center;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-ajax-pad .content-content {
|
||||
padding: .5em 20px;
|
||||
}
|
||||
|
||||
#page-manager-edit .page-manager-ajax-pad textarea {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#page-manager-edit .changed-notification {
|
||||
border: 1px solid #aaa;
|
||||
background-color: #ffe;
|
||||
color: #494949;
|
||||
padding: 1em;
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
#page-manager-edit .ctools-locked {
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
#page-manager-page-summary .title {
|
||||
font-weight: bold;
|
||||
font-size: 160%;
|
||||
}
|
||||
|
||||
#page-manager-page-summary .handler-summary {
|
||||
}
|
||||
|
||||
#page-manager-page-summary .page-summary-operation {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
#page-manager-page-summary .page-summary-label {
|
||||
width: 8em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
.handler-summary dl {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.handler-summary dt {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.handler-summary dd {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.handler-summary ol {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.handler-summary .handler-title {
|
||||
border-top: 1px solid #ddd;
|
||||
border-bottom: 1px solid #ddd;
|
||||
background: #fafafa;
|
||||
padding: 0 0 0 5px;
|
||||
margin-top: .5em;
|
||||
}
|
||||
|
||||
.handler-summary .handler-title .title-label {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
line-height: 1.75em;
|
||||
}
|
||||
|
||||
|
||||
/** Override that obnoxious float on throbber. **/
|
||||
#page-manager-edit .progress-disabled {
|
||||
float: none;
|
||||
}
|
||||
|
||||
#page-manager-edit .progress-disabled + .ajax-progress {
|
||||
float: right;
|
||||
position: relative;
|
||||
top: -2em;
|
||||
}
|
||||
|
||||
#page-manager-list-pages-form .progress-disabled + .ajax-progress {
|
||||
position: relative;
|
||||
top: 2em;
|
||||
left: -.5em;
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
The Page Manager module creates and manages pages in your Drupal site. Pages are defined as items that have a path and provide output to the user. It is a complete round trip from getting user input to providing user output.
|
||||
|
||||
There are two types of pages that the Page Manager currently supports:
|
||||
<dl>
|
||||
<dt>Custom pages</dt>
|
||||
<dd>Custom pages are defined completely by the administrator. Their path, access control and visible menu characteristics are completely arbitrary.</dd>
|
||||
<dt>System pages</dt>
|
||||
<dd>System pages are defined by Drupal and Drupal modules. They primarily override pre-existing pages to provide different functionality. They often do not allow such features as access control in favor of what already exists, and they will usually 'fall back' to default Drupal behavior.
|
||||
</dl>
|
||||
|
||||
Both types of pages figure out what to show the user by using <strong>Variants</strong>. Variants are output handlers, and every page should have at least one. Most pages will simply have only one. Pages with multiple variants will choose one and only one Variant to display content to the user and will use the <strong>Selection Rules</strong> to figure out which Variant to display.
|
@@ -0,0 +1,43 @@
|
||||
task handler definition:
|
||||
title -- visible title of the task handler.
|
||||
description -- description of the task handler.
|
||||
task type -- The type of the task this handler can service.
|
||||
render -- callback of the function to render the handler. The arguments to this callback are specific to the task type.
|
||||
admin title -- callback to render the admin title as this handler is listed.
|
||||
params: $handler, $task, $subtask_id
|
||||
admin summary -- callback to render what's in the collapsible info as the handler is listed. Optional.
|
||||
params: $handler, $task, $subtask_id
|
||||
default conf -- either an array() of default conf data or a callback that returns an array.
|
||||
params: $handler, $task, $subtask_id
|
||||
save -- callback to call just prior to the task handler being saved so it can adjust its data.
|
||||
params: &$handler, $update (as drupal_write_record would receive)
|
||||
export -- callback to call just prior to the task being exported. It should return text to append to the export if necessary.
|
||||
params: &$handler, $indent
|
||||
|
||||
forms => array(
|
||||
'id' => array(
|
||||
'form' => form callback (receives $form, $form_state)
|
||||
'submit' => submit callback
|
||||
'validate' => validate callback
|
||||
'include' => an optional file to include to get functionality for this form. Must include full path.
|
||||
'no return' => hide the 'return' button, meaning that the form requires extra steps if submitted
|
||||
'alternate next' => an alternate next form. Used for hidden edit forms that don't have tabs.
|
||||
'no blocks' => if TRUE, use Drupal's mechanism to not render blocks for this form.
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
'add forms' => array(
|
||||
'form1', => t('form title'),
|
||||
'form2', => t('form title'),
|
||||
// ...etc.../
|
||||
),
|
||||
'edit forms' => array(
|
||||
'id' => t('tab name'),
|
||||
'id2' => t('tab name'),
|
||||
),
|
||||
|
||||
If a form name is blank it is a 'hidden' form -- it has no tab but can still be reached.
|
||||
|
||||
|
||||
Notes: Because #required validation cannot be skipped when clicking cancel, please don't use it.
|
@@ -0,0 +1,2 @@
|
||||
|
||||
defines a task type, grouping tasks together and providing a common UI for them.
|
@@ -0,0 +1,38 @@
|
||||
task definition:
|
||||
title -- visible title of the task.
|
||||
description -- description of the task.
|
||||
hook menu -- function to delegate from hook_menu. Params: &$items, $task
|
||||
hook menu alter -- function to delegate from hook_menu_alter. Params: &$items, $task
|
||||
hook theme -- function to delegate from hook_theme. Params: &$items, $task
|
||||
|
||||
admin name -- if set an admin menu will appear in the delegator UI
|
||||
admin description -- to describe the admin menu
|
||||
|
||||
admin access callback -- if set, the callback to use to determine administrative
|
||||
access to this task. Defaults to user_access. Note that this is required even
|
||||
if delegator isn't handling administration, since this gets used to on handler
|
||||
edit forms.
|
||||
admin access arguments -- If set, the arguments to use to determine administrative
|
||||
access to this task. Defaults to array('administer delegator');
|
||||
|
||||
type -- The type of the task, used to determine which handlers can service it.
|
||||
|
||||
subtasks -- can be TRUE in which case it supports subtasks with the default
|
||||
configuration or a string (array?) with callbacks to fetch subtask data.
|
||||
subtask callback -- A callback which returns just one subtask. Param: $task, $subtask_id
|
||||
subtasks callback -- A callback which returns an array of all subtasks.
|
||||
This MUST return an array, even if it's empty.Param: $task
|
||||
|
||||
default handlers -- If the task contains any default handlers, they can be included here.
|
||||
|
||||
task names must not contain a - as that is used to separate the task name from the subtask ID.
|
||||
|
||||
subtasks implement data very similar to their parent task. In particular, they
|
||||
implement the following items exactly like their task:
|
||||
hook menu
|
||||
hook menu alter
|
||||
description
|
||||
admin name
|
||||
admin description
|
||||
admin access callback
|
||||
admin access arguments
|
@@ -0,0 +1,2 @@
|
||||
|
||||
Please visit <a href="http://drupal.org/node/528072">http://drupal.org/node/528072</a> to help provide this documentation page.
|
@@ -0,0 +1,2 @@
|
||||
|
||||
Please visit <a href="http://drupal.org/node/528058">http://drupal.org/node/528058</a> to help provide this documentation page.
|
@@ -0,0 +1,2 @@
|
||||
|
||||
Please visit <a href="http://drupal.org/node/528078">http://drupal.org/node/528078</a> to help provide this documentation page.
|
@@ -0,0 +1,2 @@
|
||||
|
||||
Please visit <a href="http://drupal.org/node/528050">http://drupal.org/node/528050</a> to help provide this documentation page.
|
@@ -0,0 +1,2 @@
|
||||
|
||||
Please visit <a href="http://drupal.org/node/528038">http://drupal.org/node/528038</a> to help provide this documentation page.
|
@@ -0,0 +1,2 @@
|
||||
|
||||
Please visit <a href="http://drupal.org/node/528044">http://drupal.org/node/528044</a> to help provide this documentation page.
|
@@ -0,0 +1,2 @@
|
||||
|
||||
Please visit <a href="http://drupal.org/node/528046">http://drupal.org/node/528046</a> to help provide this documentation page.
|
@@ -0,0 +1,2 @@
|
||||
|
||||
Please visit <a href="http://drupal.org/node/528040">http://drupal.org/node/528040</a> to help provide this documentation page.
|
@@ -0,0 +1,2 @@
|
||||
|
||||
Please visit <a href="http://drupal.org/node/528036">http://drupal.org/node/528036</a> to help provide this documentation page.
|
@@ -0,0 +1,15 @@
|
||||
|
||||
Note: this page is currently very preliminary. Please visit <a href="http://drupal.org/node/528034">http://drupal.org/node/528034</a> to help provide this documentation page!
|
||||
|
||||
This is a quick summary:
|
||||
|
||||
<ul>
|
||||
<li>Visit administer >> site building >> pages to get to the primary page manager interface.</li>
|
||||
<li>You can add custom pages for your basic landing pages, front pages, whatever you like for normal content display.</li>
|
||||
<li>You can use the system pages to create finer control of how taxonomy vocabularies, nodes and user profiles are displayed.</li>
|
||||
<li>When you add your first custom page, do not bother with the optional features. You will not need these until you get to more advanced tasks.</li>
|
||||
<li>The selection rules are the key to creating node displays for just one node type.</li>
|
||||
<li>Everything in this system is pluggable. A little PHP knowledge and exploration of the plugins directories can take you a long way.</li>
|
||||
</ul>
|
||||
|
||||
|
@@ -0,0 +1,4 @@
|
||||
|
||||
Additional 'task' keys support:
|
||||
|
||||
operations -- a list of operations suitable for theme('links')
|
@@ -0,0 +1,59 @@
|
||||
[advanced help settings]
|
||||
line break = TRUE
|
||||
|
||||
[about]
|
||||
title = About Page Manager
|
||||
weight = -100
|
||||
|
||||
[getting-started]
|
||||
title = Getting Started
|
||||
weight = -80
|
||||
|
||||
[getting-started-page-list]
|
||||
title = The page list
|
||||
weight = -90
|
||||
parent = getting-started
|
||||
|
||||
[getting-started-create]
|
||||
title = Creating a page
|
||||
weight = -80
|
||||
parent = getting-started
|
||||
|
||||
[getting-started-members]
|
||||
title = Tutorial: Make a page that looks different for members
|
||||
weight = -70
|
||||
parent = getting-started
|
||||
|
||||
[getting-started-custom-nodes]
|
||||
title = Tutorial: Customize the look of a single node type
|
||||
weight = -60
|
||||
parent = getting-started
|
||||
|
||||
[getting-started-custom-vocabulary]
|
||||
title = Tutorial: Customize the look of a single taxonomy vocabulary
|
||||
weight = -50
|
||||
parent = getting-started
|
||||
|
||||
[custom-pages]
|
||||
title = Custom pages
|
||||
weight = -50
|
||||
|
||||
[custom-pages-arguments]
|
||||
title = Arguments
|
||||
weight = -100
|
||||
parent = custom-pages
|
||||
|
||||
[custom-pages-access]
|
||||
title = Access control
|
||||
weight = -90
|
||||
parent = custom-pages
|
||||
|
||||
[custom-pages-menu]
|
||||
title = Menu items
|
||||
weight = -80
|
||||
parent = custom-pages
|
||||
|
||||
[variants]
|
||||
title = Variants
|
||||
weight = -40
|
||||
|
@@ -0,0 +1,2 @@
|
||||
|
||||
Please visit <a href="http://drupal.org/node/528078">http://drupal.org/node/528078</a> to help provide this documentation page.
|
Binary file not shown.
After Width: | Height: | Size: 313 B |
Binary file not shown.
After Width: | Height: | Size: 262 B |
Binary file not shown.
After Width: | Height: | Size: 273 B |
@@ -0,0 +1,44 @@
|
||||
|
||||
/**
|
||||
* Provide some extra responses for the page list so we can have automatic
|
||||
* on change.
|
||||
*/
|
||||
|
||||
Drupal.behaviors.PageManagerList = function() {
|
||||
var timeoutID = 0;
|
||||
$('form#page-manager-list-pages-form select:not(.pm-processed)')
|
||||
.addClass('pm-processed')
|
||||
.change(function() {
|
||||
$('#edit-pages-apply').click();
|
||||
});
|
||||
$('form#page-manager-list-pages-form input[type=text]:not(.pm-processed)')
|
||||
.addClass('pm-processed')
|
||||
.keyup(function(e) {
|
||||
switch (e.keyCode) {
|
||||
case 16: // shift
|
||||
case 17: // ctrl
|
||||
case 18: // alt
|
||||
case 20: // caps lock
|
||||
case 33: // page up
|
||||
case 34: // page down
|
||||
case 35: // end
|
||||
case 36: // home
|
||||
case 37: // left arrow
|
||||
case 38: // up arrow
|
||||
case 39: // right arrow
|
||||
case 40: // down arrow
|
||||
case 9: // tab
|
||||
case 13: // enter
|
||||
case 27: // esc
|
||||
return false;
|
||||
default:
|
||||
if (!$('#edit-pages-apply').hasClass('ctools-ajaxing')) {
|
||||
if ((timeoutID)) {
|
||||
clearTimeout(timeoutID);
|
||||
}
|
||||
|
||||
timeoutID = setTimeout(function() { $('#edit-pages-apply').click(); }, 300);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Describe hooks provided by the Page Manager module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup hooks
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @todo.
|
||||
*
|
||||
* @param array $result
|
||||
* @todo.
|
||||
* @param object $page
|
||||
* @todo.
|
||||
*/
|
||||
function hook_page_manager_operations_alter(&$result, &$page) {
|
||||
// @todo.
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo.
|
||||
*
|
||||
* @param array $operations
|
||||
* @todo.
|
||||
* @param object $handler
|
||||
* @todo.
|
||||
*/
|
||||
function hook_page_manager_variant_operations_alter(&$operations, &$handler) {
|
||||
// @todo.
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup hooks".
|
||||
*/
|
@@ -0,0 +1,12 @@
|
||||
name = Page manager
|
||||
description = Provides a UI and API to manage pages within the site.
|
||||
core = 7.x
|
||||
dependencies[] = ctools
|
||||
package = Chaos tool suite
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-04-03
|
||||
version = "7.x-1.3"
|
||||
core = "7.x"
|
||||
project = "ctools"
|
||||
datestamp = "1365013512"
|
||||
|
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installation routines for page manager module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_schema().
|
||||
*/
|
||||
function page_manager_schema() {
|
||||
// This should always point to our 'current' schema. This makes it relatively easy
|
||||
// to keep a record of schema as we make changes to it.
|
||||
return page_manager_schema_1();
|
||||
}
|
||||
|
||||
/**
|
||||
* Schema version 1 for Panels in D6.
|
||||
*/
|
||||
function page_manager_schema_1() {
|
||||
$schema['page_manager_handlers'] = array(
|
||||
'export' => array(
|
||||
'identifier' => 'handler',
|
||||
'bulk export' => TRUE,
|
||||
'export callback' => 'page_manager_export_task_handler',
|
||||
'load callback' => 'page_manager_export_task_handler_load',
|
||||
'delete callback' => 'page_manager_delete_task_handler',
|
||||
'primary key' => 'did',
|
||||
'api' => array(
|
||||
'owner' => 'page_manager',
|
||||
'api' => 'pages_default',
|
||||
'minimum_version' => 1,
|
||||
'current_version' => 1,
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'did' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
|
||||
'no export' => TRUE,
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => '255',
|
||||
'description' => 'Unique ID for this task handler. Used to identify it programmatically.',
|
||||
),
|
||||
'task' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => '64',
|
||||
'description' => 'ID of the task this handler is for.',
|
||||
),
|
||||
'subtask' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => '64',
|
||||
'description' => 'ID of the subtask this handler is for.',
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'handler' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => '64',
|
||||
'description' => 'ID of the task handler being used.',
|
||||
),
|
||||
'weight' => array(
|
||||
'type' => 'int',
|
||||
'description' => 'The order in which this handler appears. Lower numbers go first.',
|
||||
),
|
||||
'conf' => array(
|
||||
'type' => 'text',
|
||||
'size' => 'big',
|
||||
'description' => 'Serialized configuration of the handler, if needed.',
|
||||
'not null' => TRUE,
|
||||
'serialize' => TRUE,
|
||||
'object default' => array(),
|
||||
),
|
||||
),
|
||||
'primary key' => array('did'),
|
||||
'unique keys' => array(
|
||||
'name' => array('name'),
|
||||
),
|
||||
'indexes' => array('fulltask' => array('task', 'subtask', 'weight')),
|
||||
);
|
||||
|
||||
$schema['page_manager_weights'] = array(
|
||||
'description' => 'Contains override weights for page_manager handlers that are in code.',
|
||||
'fields' => array(
|
||||
'name' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => '255',
|
||||
'description' => 'Unique ID for this task handler. Used to identify it programmatically.',
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'weight' => array(
|
||||
'type' => 'int',
|
||||
'description' => 'The order in which this handler appears. Lower numbers go first.',
|
||||
),
|
||||
),
|
||||
'primary key' => array('name'),
|
||||
'indexes' => array(
|
||||
'weights' => array('name', 'weight'),
|
||||
),
|
||||
);
|
||||
|
||||
$schema['page_manager_pages'] = array(
|
||||
'description' => 'Contains page subtasks for implementing pages with arbitrary tasks.',
|
||||
'export' => array(
|
||||
'identifier' => 'page',
|
||||
'bulk export' => TRUE,
|
||||
'export callback' => 'page_manager_page_export',
|
||||
'api' => array(
|
||||
'owner' => 'page_manager',
|
||||
'api' => 'pages_default',
|
||||
'minimum_version' => 1,
|
||||
'current_version' => 1,
|
||||
),
|
||||
),
|
||||
'fields' => array(
|
||||
'pid' => array(
|
||||
'type' => 'serial',
|
||||
'not null' => TRUE,
|
||||
'description' => 'Primary ID field for the table. Not used for anything except internal lookups.',
|
||||
'no export' => TRUE,
|
||||
),
|
||||
'name' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => '255',
|
||||
'description' => 'Unique ID for this subtask. Used to identify it programmatically.',
|
||||
),
|
||||
'task' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => '64',
|
||||
'description' => 'What type of page this is, so that we can use the same mechanism for creating tighter UIs for targeted pages.',
|
||||
'default' => 'page',
|
||||
),
|
||||
'admin_title' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => '255',
|
||||
'description' => 'Human readable title for this page subtask.',
|
||||
),
|
||||
'admin_description' => array(
|
||||
'type' => 'text',
|
||||
'size' => 'big',
|
||||
'description' => 'Administrative description of this item.',
|
||||
'object default' => '',
|
||||
),
|
||||
'path' => array(
|
||||
'type' => 'varchar',
|
||||
'length' => '255',
|
||||
'description' => 'The menu path that will invoke this task.',
|
||||
),
|
||||
'access' => array(
|
||||
'type' => 'text',
|
||||
'size' => 'big',
|
||||
'description' => 'Access configuration for this path.',
|
||||
'not null' => TRUE,
|
||||
'serialize' => TRUE,
|
||||
'object default' => array(),
|
||||
),
|
||||
'menu' => array(
|
||||
'type' => 'text',
|
||||
'size' => 'big',
|
||||
'description' => 'Serialized configuration of Drupal menu visibility settings for this item.',
|
||||
'not null' => TRUE,
|
||||
'serialize' => TRUE,
|
||||
'object default' => array(),
|
||||
),
|
||||
'arguments' => array(
|
||||
'type' => 'text',
|
||||
'size' => 'big',
|
||||
'description' => 'Configuration of arguments for this menu item.',
|
||||
'not null' => TRUE,
|
||||
'serialize' => TRUE,
|
||||
'object default' => array(),
|
||||
),
|
||||
'conf' => array(
|
||||
'type' => 'text',
|
||||
'size' => 'big',
|
||||
'description' => 'Serialized configuration of the page, if needed.',
|
||||
'not null' => TRUE,
|
||||
'serialize' => TRUE,
|
||||
'object default' => array(),
|
||||
),
|
||||
),
|
||||
'primary key' => array('pid'),
|
||||
'unique keys' => array(
|
||||
'name' => array('name'),
|
||||
),
|
||||
'indexes' => array('task' => array('task')),
|
||||
);
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_install().
|
||||
*/
|
||||
function page_manager_install() {
|
||||
db_update('system')
|
||||
->fields(array('weight' => 99))
|
||||
->condition('name', 'page_manager')
|
||||
->execute();
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,286 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* This is the task handler plugin to handle generating 403, 404 and 301 response codes.
|
||||
*/
|
||||
|
||||
// Plugin definition
|
||||
$plugin = array(
|
||||
// is a 'context' handler type, meaning it supports the API of the
|
||||
// context handlers provided by ctools context plugins.
|
||||
'handler type' => 'context',
|
||||
'visible' => TRUE, // may be added up front.
|
||||
|
||||
// Administrative fields.
|
||||
'title' => t('HTTP response code'),
|
||||
'admin summary' => 'page_manager_http_response_admin_summary',
|
||||
'admin title' => 'page_manager_http_response_title',
|
||||
'operations' => array(
|
||||
'settings' => array(
|
||||
'title' => t('General'),
|
||||
'description' => t('Change general settings for this variant.'),
|
||||
'form' => 'page_manager_http_response_edit_settings',
|
||||
),
|
||||
'criteria' => array(
|
||||
'title' => t('Selection rules'),
|
||||
'description' => t('Control the criteria used to decide whether or not this variant is used.'),
|
||||
'ajax' => FALSE,
|
||||
'form' => array(
|
||||
'order' => array(
|
||||
'form' => t('Selection rules'),
|
||||
),
|
||||
'forms' => array(
|
||||
'form' => array(
|
||||
'include' => drupal_get_path('module', 'ctools') . '/includes/context-task-handler.inc',
|
||||
'form id' => 'ctools_context_handler_edit_criteria',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
'context' => array(
|
||||
'title' => t('Contexts'),
|
||||
'ajax' => FALSE,
|
||||
'description' => t('Add additional context objects to this variant that can be used by the content.'),
|
||||
'form' => array(
|
||||
'order' => array(
|
||||
'form' => t('Context'),
|
||||
),
|
||||
'forms' => array(
|
||||
'form' => array(
|
||||
'include' => drupal_get_path('module', 'ctools') . '/includes/context-task-handler.inc',
|
||||
'form id' => 'ctools_context_handler_edit_context',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Callback to render the data.
|
||||
'render' => 'page_manager_http_response_render',
|
||||
|
||||
'add features' => array(
|
||||
'criteria' => t('Selection rules'),
|
||||
'context' => t('Contexts'),
|
||||
),
|
||||
// Where to go when finished.
|
||||
'add finish' => 'settings',
|
||||
|
||||
'required forms' => array(
|
||||
'settings' => t('Panel settings'),
|
||||
),
|
||||
|
||||
'edit forms' => array(
|
||||
'criteria' => t('Selection rules'),
|
||||
'settings' => t('General'),
|
||||
'context' => t('Contexts'),
|
||||
),
|
||||
'forms' => array(
|
||||
'settings' => array(
|
||||
'form id' => 'page_manager_http_response_edit_settings',
|
||||
),
|
||||
'context' => array(
|
||||
'include' => drupal_get_path('module', 'ctools') . '/includes/context-task-handler.inc',
|
||||
'form id' => 'ctools_context_handler_edit_context',
|
||||
),
|
||||
'criteria' => array(
|
||||
'include' => drupal_get_path('module', 'ctools') . '/includes/context-task-handler.inc',
|
||||
'form id' => 'ctools_context_handler_edit_criteria',
|
||||
),
|
||||
),
|
||||
'default conf' => array(
|
||||
'title' => t('HTTP response code'),
|
||||
'contexts' => array(),
|
||||
'relationships' => array(),
|
||||
'code' => '404',
|
||||
'destination' => '',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Provide a list of the response codes we support.
|
||||
*
|
||||
* Abstracted so it can be more readily used both on input and output.
|
||||
*/
|
||||
function page_manager_http_response_codes() {
|
||||
return array(
|
||||
403 => t('403 Access denied'),
|
||||
404 => t('404 Page not found'),
|
||||
410 => t('410 Gone'),
|
||||
301 => t('301 Redirect'),
|
||||
);
|
||||
}
|
||||
|
||||
function page_manager_http_response_admin_summary($handler, $task, $subtask, $page, $show_title = TRUE) {
|
||||
$task_name = page_manager_make_task_name($task['name'], $subtask['name']);
|
||||
$output = '';
|
||||
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
|
||||
// Get the operations
|
||||
$operations = page_manager_get_operations($page);
|
||||
|
||||
// Get operations for just this handler.
|
||||
$operations = $operations['handlers']['children'][$handler->name]['children']['actions']['children'];
|
||||
$args = array('handlers', $handler->name, 'actions');
|
||||
$rendered_operations = page_manager_render_operations($page, $operations, array(), array('class' => array('actions')), 'actions', $args);
|
||||
|
||||
$plugin = page_manager_get_task_handler($handler->handler);
|
||||
|
||||
$object = ctools_context_handler_get_task_object($task, $subtask, $handler);
|
||||
$context = ctools_context_load_contexts($object, TRUE);
|
||||
|
||||
$access = ctools_access_group_summary(!empty($handler->conf['access']) ? $handler->conf['access'] : array(), $context);
|
||||
if ($access) {
|
||||
$access = t('This panel will be selected if @conditions.', array('@conditions' => $access));
|
||||
}
|
||||
else {
|
||||
$access = t('This panel will always be selected.');
|
||||
}
|
||||
|
||||
$rows = array();
|
||||
|
||||
$type = $handler->type == t('Default') ? t('In code') : $handler->type;
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-label'), 'data' => t('Storage')),
|
||||
array('class' => array('page-summary-data'), 'data' => $type),
|
||||
array('class' => array('page-summary-operation'), 'data' => ''),
|
||||
);
|
||||
|
||||
if (!empty($handler->disabled)) {
|
||||
$link = l(t('Enable'), page_manager_edit_url($task_name, array('handlers', $handler->name, 'actions', 'enable')));
|
||||
$text = t('Disabled');
|
||||
}
|
||||
else {
|
||||
$link = l(t('Disable'), page_manager_edit_url($task_name, array('handlers', $handler->name, 'actions', 'disable')));
|
||||
$text = t('Enabled');
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-label'), 'data' => t('Status')),
|
||||
array('class' => array('page-summary-data'), 'data' => $text),
|
||||
array('class' => array('page-summary-operation'), 'data' => $link),
|
||||
);
|
||||
|
||||
$link = l(t('Edit'), page_manager_edit_url($task_name, array('handlers', $handler->name, 'criteria')));
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-label'), 'data' => t('Selection rule')),
|
||||
array('class' => array('page-summary-data'), 'data' => $access),
|
||||
array('class' => array('page-summary-operation'), 'data' => $link),
|
||||
);
|
||||
|
||||
$link = l(t('Edit'), page_manager_edit_url($task_name, array('handlers', $handler->name, 'settings')));
|
||||
$codes = page_manager_http_response_codes();
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-label'), 'data' => t('Response code')),
|
||||
array('class' => array('page-summary-data'), 'data' => $codes[$handler->conf['code']]),
|
||||
array('class' => array('page-summary-operation'), 'data' => $link),
|
||||
);
|
||||
|
||||
$info = theme('table', array('header' => array(), 'rows' => $rows, 'attributes' => array('class' => array('page-manager-handler-summary'))));
|
||||
|
||||
$title = $handler->conf['title'];
|
||||
if ($title != t('Panel')) {
|
||||
$title = t('Panel: @title', array('@title' => $title));
|
||||
}
|
||||
|
||||
$output .= '<div class="clearfix">';
|
||||
if ($show_title) {
|
||||
$output .= '<div class="handler-title clearfix">';
|
||||
$output .= '<div class="actions handler-actions">' . $rendered_operations['actions'] . '</div>';
|
||||
$output .= '<span class="title-label">' . $title . '</span>';
|
||||
}
|
||||
|
||||
$output .= '</div>';
|
||||
$output .= $info;
|
||||
$output .= '</div>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up a title for the panel based upon the selection rules.
|
||||
*/
|
||||
function page_manager_http_response_title($handler, $task, $subtask) {
|
||||
if (isset($handler->conf['title'])) {
|
||||
return check_plain($handler->conf['title']);
|
||||
}
|
||||
else {
|
||||
return t('HTTP response code');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* General settings for the panel
|
||||
*/
|
||||
function page_manager_http_response_edit_settings($form, &$form_state) {
|
||||
$conf = $form_state['handler']->conf;
|
||||
$form['title'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $conf['title'],
|
||||
'#title' => t('Administrative title'),
|
||||
'#description' => t('Administrative title of this variant.'),
|
||||
);
|
||||
|
||||
$form['code'] = array(
|
||||
'#title' => t('Response code'),
|
||||
'#type' => 'select',
|
||||
'#options' => page_manager_http_response_codes(),
|
||||
'#default_value' => $conf['code'],
|
||||
);
|
||||
|
||||
ctools_include('dependent');
|
||||
$form['destination'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Redirect destination'),
|
||||
'#default_value' => $conf['destination'],
|
||||
'#dependency' => array('edit-code' => array(301)),
|
||||
'#description' => t('Enter the path to redirect to. You may use keyword substitutions from contexts. You can use external urls (http://www.example.com/foo) or internal urls (node/1).'),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function page_manager_http_response_edit_settings_submit($form, &$form_state) {
|
||||
$form_state['handler']->conf['title'] = $form_state['values']['title'];
|
||||
$form_state['handler']->conf['code'] = $form_state['values']['code'];
|
||||
$form_state['handler']->conf['destination'] = $form_state['values']['destination'];
|
||||
}
|
||||
|
||||
function page_manager_http_response_render($handler, $base_contexts, $args, $test = TRUE) {
|
||||
// Go through arguments and see if they match.
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
|
||||
// Add my contexts
|
||||
$contexts = ctools_context_handler_get_handler_contexts($base_contexts, $handler);
|
||||
|
||||
// Test.
|
||||
if ($test && !ctools_context_handler_select($handler, $contexts)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($handler->handler)) {
|
||||
ctools_context_handler_pre_render($handler, $contexts, $args);
|
||||
}
|
||||
|
||||
$info['response code'] = $handler->conf['code'];
|
||||
if ($info['response code'] == 301) {
|
||||
$path = ctools_context_keyword_substitute($handler->conf['destination'], array(), $contexts);
|
||||
$url = parse_url($path);
|
||||
if (isset($url['query'])) {
|
||||
$path = strtr($path, array('?' . $url['query'] => ''));
|
||||
$info['query'] = drupal_get_query_array($url['query']);
|
||||
}
|
||||
if (isset($url['fragment'])) {
|
||||
$path = strtr($path, array('#' . $url['fragment'] => ''));
|
||||
$info['fragment'] = $url['fragment'];
|
||||
}
|
||||
|
||||
$info['destination'] = rtrim($path, '?');
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
|
||||
* more information.
|
||||
*/
|
||||
function page_manager_blog_page_manager_tasks() {
|
||||
if (!module_exists('blog')) {
|
||||
return;
|
||||
}
|
||||
|
||||
return array(
|
||||
// This is a 'page' task and will fall under the page admin UI
|
||||
'task type' => 'page',
|
||||
|
||||
'title' => t('All blogs'),
|
||||
'admin title' => t('All blogs'),
|
||||
'admin description' => t('When enabled, this overrides the default Drupal behavior for the all blogs at <em>/blog</em>. If no variant is selected, the default Drupal most recent blog posts will be shown.'),
|
||||
'admin path' => 'blog',
|
||||
|
||||
// Menu hooks so that we can alter the node/%node menu entry to point to us.
|
||||
'hook menu alter' => 'page_manager_blog_menu_alter',
|
||||
|
||||
// This is task uses 'context' handlers and must implement these to give the
|
||||
// handler data it needs.
|
||||
'handler type' => 'context',
|
||||
|
||||
// Allow this to be enabled or disabled:
|
||||
'disabled' => variable_get('page_manager_blog_disabled', TRUE),
|
||||
'enable callback' => 'page_manager_blog_enable',
|
||||
'access callback' => 'page_manager_blog_access_check',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback defined by page_manager_blog_page_manager_tasks().
|
||||
*
|
||||
* Alter the node edit input so that node edit comes to us rather than the
|
||||
* normal node edit process.
|
||||
*/
|
||||
function page_manager_blog_menu_alter(&$items, $task) {
|
||||
if (variable_get('page_manager_blog_disabled', TRUE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$callback = $items['blog']['page callback'];
|
||||
// Override the node edit handler for our purpose.
|
||||
if ($callback == 'blog_page_last' || variable_get('page_manager_override_anyway', FALSE)) {
|
||||
$items['blog']['page callback'] = 'page_manager_blog';
|
||||
$items['blog']['file path'] = $task['path'];
|
||||
$items['blog']['file'] = $task['file'];
|
||||
}
|
||||
else {
|
||||
variable_set('page_manager_blog_disabled', TRUE);
|
||||
if (!empty($GLOBALS['page_manager_enabling_blog'])) {
|
||||
drupal_set_message(t('Page manager module is unable to enable blog because some other module already has overridden with %callback.', array('%callback' => $callback)), 'warning');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for our overridden node edit.
|
||||
*
|
||||
* This function asks its assigned handlers who, if anyone, would like
|
||||
* to run with it. If no one does, it passes through to Drupal core's
|
||||
* node edit, which is node_page_edit().
|
||||
*/
|
||||
function page_manager_blog() {
|
||||
// Load my task plugin
|
||||
$task = page_manager_get_task('blog');
|
||||
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
$output = ctools_context_handler_render($task, '', array(), array());
|
||||
if ($output !== FALSE) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
module_load_include('inc', 'blog', 'blog.pages');
|
||||
$function = 'blog_page_last';
|
||||
foreach (module_implements('page_manager_override') as $module) {
|
||||
$call = $module . '_page_manager_override';
|
||||
if (($rc = $call('blog')) && function_exists($rc)) {
|
||||
$function = $rc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, fall back.
|
||||
return $function();
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to enable/disable the page from the UI.
|
||||
*/
|
||||
function page_manager_blog_enable($cache, $status) {
|
||||
variable_set('page_manager_blog_disabled', $status);
|
||||
// Set a global flag so that the menu routine knows it needs
|
||||
// to set a message if enabling cannot be done.
|
||||
if (!$status) {
|
||||
$GLOBALS['page_manager_enabling_blog'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine if a page is accessible.
|
||||
*
|
||||
* @param $task
|
||||
* The task plugin.
|
||||
* @param $subtask_id
|
||||
* The subtask id
|
||||
* @param $contexts
|
||||
* The contexts loaded for the task.
|
||||
* @return
|
||||
* TRUE if the current user can access the page.
|
||||
*/
|
||||
function page_manager_blog_access_check($task, $subtask_id, $contexts) {
|
||||
return user_access('access content');
|
||||
}
|
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
|
||||
* more information.
|
||||
*/
|
||||
function page_manager_blog_user_page_manager_tasks() {
|
||||
if (!module_exists('blog')) {
|
||||
return;
|
||||
}
|
||||
|
||||
return array(
|
||||
// This is a 'page' task and will fall under the page admin UI
|
||||
'task type' => 'page',
|
||||
'title' => t('User blog'),
|
||||
'admin title' => t('User blog'),
|
||||
'admin description' => t('When enabled, this overrides the default Drupal behavior for displaying user blogs at <em>blog/%user</em>. If no variant is selected, the default Drupal user blog will be used.'),
|
||||
'admin path' => 'blog/%user',
|
||||
|
||||
// Callback to add items to the page managertask administration form:
|
||||
'task admin' => 'page_manager_blog_user_task_admin',
|
||||
|
||||
'hook menu alter' => 'page_manager_blog_user_menu_alter',
|
||||
|
||||
// This is task uses 'context' handlers and must implement these to give the
|
||||
// handler data it needs.
|
||||
'handler type' => 'context', // handler type -- misnamed
|
||||
'get arguments' => 'page_manager_blog_user_get_arguments',
|
||||
'get context placeholders' => 'page_manager_blog_user_get_contexts',
|
||||
|
||||
// Allow this to be enabled or disabled:
|
||||
'disabled' => variable_get('page_manager_blog_user_disabled', TRUE),
|
||||
'enable callback' => 'page_manager_blog_user_enable',
|
||||
'access callback' => 'page_manager_blog_user_access_check',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback defined by page_manager_blog_user_page_manager_tasks().
|
||||
*
|
||||
* Alter the user view input so that user view comes to us rather than the
|
||||
* normal user view process.
|
||||
*/
|
||||
function page_manager_blog_user_menu_alter(&$items, $task) {
|
||||
if (variable_get('page_manager_blog_user_disabled', TRUE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Override the user view handler for our purpose.
|
||||
if ($items['blog/%user_uid_optional']['page callback'] == 'blog_page_user' || variable_get('page_manager_override_anyway', FALSE)) {
|
||||
$items['blog/%user_uid_optional']['page callback'] = 'page_manager_blog_user';
|
||||
$items['blog/%user_uid_optional']['file path'] = $task['path'];
|
||||
$items['blog/%user_uid_optional']['file'] = $task['file'];
|
||||
}
|
||||
else {
|
||||
// automatically disable this task if it cannot be enabled.
|
||||
variable_set('page_manager_blog_user_disabled', TRUE);
|
||||
if (!empty($GLOBALS['page_manager_enabling_blog_user'])) {
|
||||
drupal_set_message(t('Page manager module is unable to enable blog/%user because some other module already has overridden with %callback.', array('%callback' => $items['blog/%user']['page callback'])), 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for our overridden user view.
|
||||
*
|
||||
* This function asks its assigned handlers who, if anyone, would like
|
||||
* to run with it. If no one does, it passes through to Drupal core's
|
||||
* user view, which is user_page_view().
|
||||
*/
|
||||
function page_manager_blog_user($account) {
|
||||
// Load my task plugin:
|
||||
$task = page_manager_get_task('blog_user');
|
||||
|
||||
// Load the account into a context.
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
$contexts = ctools_context_handler_get_task_contexts($task, '', array($account));
|
||||
|
||||
$output = ctools_context_handler_render($task, '', $contexts, array($account->uid));
|
||||
if ($output !== FALSE) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
module_load_include('inc', 'blog', 'blog.pages');
|
||||
$function = 'blog_page_user';
|
||||
foreach (module_implements('page_manager_override') as $module) {
|
||||
$call = $module . '_page_manager_override';
|
||||
if (($rc = $call('blog_user')) && function_exists($rc)) {
|
||||
$function = $rc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, fall back.
|
||||
return $function($account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get arguments provided by this task handler.
|
||||
*
|
||||
* Since this is the node view and there is no UI on the arguments, we
|
||||
* create dummy arguments that contain the needed data.
|
||||
*/
|
||||
function page_manager_blog_user_get_arguments($task, $subtask_id) {
|
||||
return array(
|
||||
array(
|
||||
'keyword' => 'user',
|
||||
'identifier' => t('User being viewed'),
|
||||
'id' => 1,
|
||||
'name' => 'uid',
|
||||
'settings' => array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get context placeholders provided by this handler.
|
||||
*/
|
||||
function page_manager_blog_user_get_contexts($task, $subtask_id) {
|
||||
return ctools_context_get_placeholders_from_argument(page_manager_blog_user_get_arguments($task, $subtask_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to enable/disable the page from the UI.
|
||||
*/
|
||||
function page_manager_blog_user_enable($cache, $status) {
|
||||
variable_set('page_manager_blog_user_disabled', $status);
|
||||
|
||||
// Set a global flag so that the menu routine knows it needs
|
||||
// to set a message if enabling cannot be done.
|
||||
if (!$status) {
|
||||
$GLOBALS['page_manager_enabling_blog_user'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine if a page is accessible.
|
||||
*
|
||||
* @param $task
|
||||
* The task plugin.
|
||||
* @param $subtask_id
|
||||
* The subtask id
|
||||
* @param $contexts
|
||||
* The contexts loaded for the task.
|
||||
* @return
|
||||
* TRUE if the current user can access the page.
|
||||
*/
|
||||
function page_manager_blog_user_access_check($task, $subtask_id, $contexts) {
|
||||
$context = reset($contexts);
|
||||
return blog_page_user_access($context->data);
|
||||
}
|
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
/**
|
||||
* Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
|
||||
* more information.
|
||||
*/
|
||||
function page_manager_comment_reply_page_manager_tasks() {
|
||||
if (!module_exists('comment')) {
|
||||
return;
|
||||
}
|
||||
|
||||
return array(
|
||||
// This is a 'page' task and will fall under the page admin UI
|
||||
'task type' => 'page',
|
||||
|
||||
'title' => t('Comment Reply page'),
|
||||
'admin title' => t('Comment Reply page'),
|
||||
'admin description' => t('When enabled, this overrides the default Drupal behavior for the site contact page at <em>/contact</em>. If no variant is selected, the default Drupal contact form will be used.'),
|
||||
'admin path' => 'comment/reply/%node',
|
||||
|
||||
// Menu hooks so that we can alter the node/%node menu entry to point to us.
|
||||
'hook menu alter' => 'page_manager_comment_reply_menu_alter',
|
||||
|
||||
// This is task uses 'context' handlers and must implement these to give the
|
||||
// handler data it needs.
|
||||
'handler type' => 'context',
|
||||
'get arguments' => 'page_manager_comment_reply_get_arguments',
|
||||
'get context placeholders' => 'page_manager_comment_reply_get_contexts',
|
||||
|
||||
// Allow this to be enabled or disabled:
|
||||
'disabled' => variable_get('page_manager_comment_reply_disabled', TRUE),
|
||||
'enable callback' => 'page_manager_comment_reply_enable',
|
||||
'access callback' => 'page_manager_comment_reply_check',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to enable/disable the page from the UI.
|
||||
*/
|
||||
function page_manager_comment_reply_enable($cache, $status) {
|
||||
variable_set('page_manager_comment_reply_disabled', $status);
|
||||
// Set a global flag so that the menu routine knows it needs
|
||||
// to set a message if enabling cannot be done.
|
||||
if (!$status) {
|
||||
$GLOBALS['page_manager_enabling_comment_reply'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Entry point for our overridden comment.
|
||||
*
|
||||
*/
|
||||
function page_manager_comment_reply_page($node, $pid = NULL){
|
||||
// Load my task plugin
|
||||
$task = page_manager_get_task('comment_reply');
|
||||
|
||||
// Load the node into a context.
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
|
||||
$contexts = ctools_context_handler_get_task_contexts($task, '', array($node, $pid));
|
||||
|
||||
if (array_key_exists('argument_cid_3', $contexts) && $contexts['argument_cid_3']->data->nid != $node->nid) {
|
||||
// Attempting to reply to a comment not belonging to the current nid.
|
||||
drupal_set_message(t('The comment you are replying to does not exist.'), 'error');
|
||||
drupal_goto("node/$node->nid");
|
||||
}
|
||||
|
||||
$output = ctools_context_handler_render($task, '', $contexts, array($node, $pid));
|
||||
if ($output != FALSE) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
$function = 'comment_reply';
|
||||
foreach (module_implements('page_manager_override') as $module) {
|
||||
$call = $module . '_page_manager_override';
|
||||
if (($rc = $call('comment_reply')) && function_exists($rc)) {
|
||||
$function = $rc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
module_load_include('inc', 'comment', 'comment.pages');
|
||||
return $function($node, $pid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get arguments provided by this task handler.
|
||||
*
|
||||
* Since this is the node view and there is no UI on the arguments, we
|
||||
* create dummy arguments that contain the needed data.
|
||||
*/
|
||||
function page_manager_comment_reply_get_arguments($task, $subtask_id) {
|
||||
return array(
|
||||
array(
|
||||
'keyword' => 'node',
|
||||
'identifier' => t('Node being commented on'),
|
||||
'id' => 2,
|
||||
'name' => 'entity_id:node',
|
||||
'settings' => array(),
|
||||
),
|
||||
array(
|
||||
'keyword' => 'comment',
|
||||
'identifier' => t('Comment being replied to'),
|
||||
'id' => 3,
|
||||
'name' => 'entity_id:comment',
|
||||
'settings' => array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get context placeholders provided by this handler.
|
||||
*/
|
||||
function page_manager_comment_reply_get_contexts($task, $subtask_id) {
|
||||
return ctools_context_get_placeholders_from_argument(page_manager_comment_reply_get_arguments($task, $subtask_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback defined by page_manager_node_view_page_manager_tasks().
|
||||
*
|
||||
* Alter the node view input so that node view comes to us rather than the
|
||||
* normal node view process.
|
||||
*/
|
||||
function page_manager_comment_reply_menu_alter(&$items, $task) {
|
||||
if (variable_get('page_manager_comment_reply_disabled', TRUE)) {
|
||||
return;
|
||||
}
|
||||
// Override the node view handler for our purpose.
|
||||
$callback = $items['comment/reply/%node']['page callback'];
|
||||
if ($callback == 'comment_reply' || variable_get('page_manager_override_anyway', FALSE)) {
|
||||
$items['comment/reply/%node']['page callback'] = 'page_manager_comment_reply_page';
|
||||
$items['comment/reply/%node']['file path'] = $task['path'];
|
||||
$items['comment/reply/%node']['file'] = $task['file'];
|
||||
}
|
||||
else {
|
||||
// automatically disable this task if it cannot be enabled.
|
||||
variable_set('page_manager_comment_reply_disabled', TRUE);
|
||||
if (!empty($GLOBALS['page_manager_enabling_comment_reply'])) {
|
||||
drupal_set_message(t('Page manager module is unable to enable comment/reply/%node because some other module already has overridden with %callback.', array('%callback' => $callback)), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// @todo override node revision handler as well?
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine if a page is accessible.
|
||||
*
|
||||
* @param $task
|
||||
* The task plugin.
|
||||
* @param $subtask_id
|
||||
* The subtask id
|
||||
* @param $contexts
|
||||
* The contexts loaded for the task.
|
||||
* @return
|
||||
* TRUE if the current user can access the page.
|
||||
*/
|
||||
function page_manager_comment_reply_access_check($task, $subtask_id, $contexts) {
|
||||
$context = reset($contexts);
|
||||
return TRUE;
|
||||
}
|
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
|
||||
* more information.
|
||||
*/
|
||||
function page_manager_contact_site_page_manager_tasks() {
|
||||
if (!module_exists('contact')) {
|
||||
return;
|
||||
}
|
||||
|
||||
return array(
|
||||
// This is a 'page' task and will fall under the page admin UI
|
||||
'task type' => 'page',
|
||||
|
||||
'title' => t('Site contact page'),
|
||||
'admin title' => t('Site contact page'),
|
||||
'admin description' => t('When enabled, this overrides the default Drupal behavior for the site contact page at <em>/contact</em>. If no variant is selected, the default Drupal contact form will be used.'),
|
||||
'admin path' => 'contact',
|
||||
|
||||
// Menu hooks so that we can alter the node/%node menu entry to point to us.
|
||||
'hook menu alter' => 'page_manager_contact_site_menu_alter',
|
||||
|
||||
// This is task uses 'context' handlers and must implement these to give the
|
||||
// handler data it needs.
|
||||
'handler type' => 'context',
|
||||
|
||||
// Allow this to be enabled or disabled:
|
||||
'disabled' => variable_get('page_manager_contact_site_disabled', TRUE),
|
||||
'enable callback' => 'page_manager_contact_site_enable',
|
||||
'access callback' => 'page_manager_contact_access_check',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback defined by page_manager_contact_site_page_manager_tasks().
|
||||
*
|
||||
* Alter the node edit input so that node edit comes to us rather than the
|
||||
* normal node edit process.
|
||||
*/
|
||||
function page_manager_contact_site_menu_alter(&$items, $task) {
|
||||
if (variable_get('page_manager_contact_site_disabled', TRUE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$callback = $items['contact']['page callback'];
|
||||
if ($callback == 'drupal_get_form') {
|
||||
$callback = $items['contact']['page arguments'][0];
|
||||
}
|
||||
|
||||
// Override the node edit handler for our purpose.
|
||||
if ($callback == 'contact_site_form' || variable_get('page_manager_override_anyway', FALSE)) {
|
||||
$items['contact']['page callback'] = 'page_manager_contact_site';
|
||||
$items['contact']['file path'] = $task['path'];
|
||||
$items['contact']['file'] = $task['file'];
|
||||
}
|
||||
else {
|
||||
variable_set('page_manager_contact_site_disabled', TRUE);
|
||||
if (!empty($GLOBALS['page_manager_enabling_contact_site'])) {
|
||||
drupal_set_message(t('Page manager module is unable to enable contact because some other module already has overridden with %callback.', array('%callback' => $callback)), 'warning');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for our overridden site contact.
|
||||
*
|
||||
* This function asks its assigned handlers who, if anyone, would like
|
||||
* to run with it. If no one does, it passes through to Drupal core's
|
||||
* node edit, which is node_page_edit().
|
||||
*/
|
||||
function page_manager_contact_site() {
|
||||
// Load my task plugin
|
||||
$task = page_manager_get_task('contact_site');
|
||||
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
$output = ctools_context_handler_render($task, '', array(), array());
|
||||
if ($output !== FALSE) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
module_load_include('inc', 'contact', 'contact.pages');
|
||||
$function = 'contact_site_form';
|
||||
foreach (module_implements('page_manager_override') as $module) {
|
||||
$call = $module . '_page_manager_override';
|
||||
if (($rc = $call('contact_site')) && function_exists($rc)) {
|
||||
$function = $rc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, fall back.
|
||||
if ($function == 'contact_site_form') {
|
||||
return drupal_get_form($function);
|
||||
}
|
||||
|
||||
return $function();
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to enable/disable the page from the UI.
|
||||
*/
|
||||
function page_manager_contact_site_enable($cache, $status) {
|
||||
variable_set('page_manager_contact_site_disabled', $status);
|
||||
// Set a global flag so that the menu routine knows it needs
|
||||
// to set a message if enabling cannot be done.
|
||||
if (!$status) {
|
||||
$GLOBALS['page_manager_enabling_contact_site'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine if a page is accessible.
|
||||
*
|
||||
* @param $task
|
||||
* The task plugin.
|
||||
* @param $subtask_id
|
||||
* The subtask id
|
||||
* @param $contexts
|
||||
* The contexts loaded for the task.
|
||||
* @return
|
||||
* TRUE if the current user can access the page.
|
||||
*/
|
||||
function page_manager_contact_access_check($task, $subtask_id, $contexts) {
|
||||
return user_access('access site-wide contact form');
|
||||
}
|
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
|
||||
* more information.
|
||||
*/
|
||||
function page_manager_contact_user_page_manager_tasks() {
|
||||
if (!module_exists('contact')) {
|
||||
return;
|
||||
}
|
||||
return array(
|
||||
// This is a 'page' task and will fall under the page admin UI
|
||||
'task type' => 'page',
|
||||
'title' => t('User contact'),
|
||||
'admin title' => t('User contact'),
|
||||
'admin description' => t('When enabled, this overrides the default Drupal behavior for displaying the user contact form at <em>user/%user/contact</em>. If no variant is selected, the default Drupal user contact form will be used.'),
|
||||
'admin path' => 'user/%user/contact',
|
||||
|
||||
// Callback to add items to the page managertask administration form:
|
||||
'task admin' => 'page_manager_contact_user_task_admin',
|
||||
|
||||
'hook menu alter' => 'page_manager_contact_user_menu_alter',
|
||||
|
||||
// This is task uses 'context' handlers and must implement these to give the
|
||||
// handler data it needs.
|
||||
'handler type' => 'context', // handler type -- misnamed
|
||||
'get arguments' => 'page_manager_contact_user_get_arguments',
|
||||
'get context placeholders' => 'page_manager_contact_user_get_contexts',
|
||||
|
||||
// Allow this to be enabled or disabled:
|
||||
'disabled' => variable_get('page_manager_contact_user_disabled', TRUE),
|
||||
'enable callback' => 'page_manager_contact_user_enable',
|
||||
'access callback' => 'page_manager_contact_user_access_check',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback defined by page_manager_contact_user_page_manager_tasks().
|
||||
*
|
||||
* Alter the user view input so that user view comes to us rather than the
|
||||
* normal user view process.
|
||||
*/
|
||||
function page_manager_contact_user_menu_alter(&$items, $task) {
|
||||
if (variable_get('page_manager_contact_user_disabled', TRUE)) {
|
||||
return;
|
||||
}
|
||||
$callback = $items['user/%user/contact']['page callback'];
|
||||
if ($callback == 'drupal_get_form') {
|
||||
$callback = $items['user/%user/contact']['page arguments'][0];
|
||||
}
|
||||
|
||||
// Override the user view handler for our purpose.
|
||||
if ($callback == 'contact_personal_form' || variable_get('page_manager_override_anyway', FALSE)) {
|
||||
$items['user/%user/contact']['page callback'] = 'page_manager_contact_user';
|
||||
$items['user/%user/contact']['file path'] = $task['path'];
|
||||
$items['user/%user/contact']['file'] = $task['file'];
|
||||
}
|
||||
else {
|
||||
// automatically disable this task if it cannot be enabled.
|
||||
variable_set('page_manager_contact_user_disabled', TRUE);
|
||||
if (!empty($GLOBALS['page_manager_enabling_contact_user'])) {
|
||||
drupal_set_message(t('Page manager module is unable to enable user/%user/contact because some other module already has overridden with %callback.', array('%callback' => $callback)), 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for our overridden user view.
|
||||
*
|
||||
* This function asks its assigned handlers who, if anyone, would like
|
||||
* to run with it. If no one does, it passes through to Drupal core's
|
||||
* user view, which is user_page_view().
|
||||
*/
|
||||
function page_manager_contact_user($form_id, $account) {
|
||||
// Load my task plugin:
|
||||
$task = page_manager_get_task('contact_user');
|
||||
|
||||
// Load the account into a context.
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
$contexts = ctools_context_handler_get_task_contexts($task, '', array($account));
|
||||
|
||||
$output = ctools_context_handler_render($task, '', $contexts, array($account->uid));
|
||||
if ($output !== FALSE) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
module_load_include('inc', 'contact', 'contact.pages');
|
||||
$function = 'contact_personal_form';
|
||||
foreach (module_implements('page_manager_override') as $module) {
|
||||
$call = $module . '_page_manager_override';
|
||||
if (($rc = $call('contact_user')) && function_exists($rc)) {
|
||||
$function = $rc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, fall back.
|
||||
return drupal_get_form($function, $account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get arguments provided by this task handler.
|
||||
*
|
||||
* Since this is the node view and there is no UI on the arguments, we
|
||||
* create dummy arguments that contain the needed data.
|
||||
*/
|
||||
function page_manager_contact_user_get_arguments($task, $subtask_id) {
|
||||
return array(
|
||||
array(
|
||||
'keyword' => 'user',
|
||||
'identifier' => t('User being viewed'),
|
||||
'id' => 1,
|
||||
'name' => 'uid',
|
||||
'settings' => array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get context placeholders provided by this handler.
|
||||
*/
|
||||
function page_manager_contact_user_get_contexts($task, $subtask_id) {
|
||||
return ctools_context_get_placeholders_from_argument(page_manager_contact_user_get_arguments($task, $subtask_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to enable/disable the page from the UI.
|
||||
*/
|
||||
function page_manager_contact_user_enable($cache, $status) {
|
||||
variable_set('page_manager_contact_user_disabled', $status);
|
||||
|
||||
// Set a global flag so that the menu routine knows it needs
|
||||
// to set a message if enabling cannot be done.
|
||||
if (!$status) {
|
||||
$GLOBALS['page_manager_enabling_contact_user'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine if a page is accessible.
|
||||
*
|
||||
* @param $task
|
||||
* The task plugin.
|
||||
* @param $subtask_id
|
||||
* The subtask id
|
||||
* @param $contexts
|
||||
* The contexts loaded for the task.
|
||||
* @return
|
||||
* TRUE if the current user can access the page.
|
||||
*/
|
||||
function page_manager_blog_contact_user_access_check($task, $subtask_id, $contexts) {
|
||||
$context = reset($contexts);
|
||||
return _contact_personal_tab_access($context->data);
|
||||
}
|
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
|
||||
* more information.
|
||||
*/
|
||||
function page_manager_node_edit_page_manager_tasks() {
|
||||
return array(
|
||||
// This is a 'page' task and will fall under the page admin UI
|
||||
'task type' => 'page',
|
||||
|
||||
'title' => t('Node add/edit form'),
|
||||
'admin title' => t('Node add/edit form'),
|
||||
'admin description' => t('When enabled, this overrides the default Drupal behavior for adding or edit nodes at <em>node/%node/edit</em> and <em>node/add/%node_type</em>. If you add variants, you may use selection criteria such as node type or language or user access to provide different edit forms for nodes. If no variant is selected, the default Drupal node edit will be used.'),
|
||||
'admin path' => 'node/%node/edit',
|
||||
|
||||
// Menu hooks so that we can alter the node/%node menu entry to point to us.
|
||||
'hook menu' => 'page_manager_node_edit_menu',
|
||||
'hook menu alter' => 'page_manager_node_edit_menu_alter',
|
||||
|
||||
// This is task uses 'context' handlers and must implement these to give the
|
||||
// handler data it needs.
|
||||
'handler type' => 'context',
|
||||
'get arguments' => 'page_manager_node_edit_get_arguments',
|
||||
'get context placeholders' => 'page_manager_node_edit_get_contexts',
|
||||
|
||||
// Allow this to be enabled or disabled:
|
||||
'disabled' => variable_get('page_manager_node_edit_disabled', TRUE),
|
||||
'enable callback' => 'page_manager_node_edit_enable',
|
||||
'access callback' => 'page_manager_node_edit_access_check',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback defined by page_manager_node_edit_page_manager_tasks().
|
||||
*
|
||||
* Alter the node edit input so that node edit comes to us rather than the
|
||||
* normal node edit process.
|
||||
*/
|
||||
function page_manager_node_edit_menu_alter(&$items, $task) {
|
||||
if (variable_get('page_manager_node_edit_disabled', TRUE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$callback = $items['node/%node/edit']['page callback'];
|
||||
// Override the node edit handler for our purpose.
|
||||
if ($callback == 'node_page_edit' || variable_get('page_manager_override_anyway', FALSE)) {
|
||||
$items['node/%node/edit']['page callback'] = 'page_manager_node_edit';
|
||||
$items['node/%node/edit']['file path'] = $task['path'];
|
||||
$items['node/%node/edit']['file'] = $task['file'];
|
||||
}
|
||||
else {
|
||||
variable_set('page_manager_node_edit_disabled', TRUE);
|
||||
if (!empty($GLOBALS['page_manager_enabling_node_edit'])) {
|
||||
drupal_set_message(t('Page manager module is unable to enable node/%node/edit because some other module already has overridden with %callback.', array('%callback' => $callback)), 'warning');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Also catch node/add handling:
|
||||
foreach (node_type_get_types() as $type) {
|
||||
$path = 'node/add/' . str_replace('_', '-', $type->type);
|
||||
if ($items[$path]['page callback'] != 'node_add') {
|
||||
if (!empty($GLOBALS['page_manager_enabling_node_edit'])) {
|
||||
drupal_set_message(t('Page manager module is unable to override @path because some other module already has overridden with %callback. Node edit will be enabled but that edit path will not be overridden.', array('@path' => $path, '%callback' => $items[$path]['page callback'])), 'warning');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$items[$path]['page callback'] = 'page_manager_node_add';
|
||||
$items[$path]['file path'] = $task['path'];
|
||||
$items[$path]['file'] = $task['file'];
|
||||
// Why str_replace things back?
|
||||
$items[$path]['page arguments'] = array($type->type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for our overridden node edit.
|
||||
*
|
||||
* This function asks its assigned handlers who, if anyone, would like
|
||||
* to run with it. If no one does, it passes through to Drupal core's
|
||||
* node edit, which is node_page_edit().
|
||||
*/
|
||||
function page_manager_node_edit($node) {
|
||||
// Load my task plugin
|
||||
$task = page_manager_get_task('node_edit');
|
||||
|
||||
// Load the node into a context.
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
$contexts = ctools_context_handler_get_task_contexts($task, '', array($node));
|
||||
|
||||
$arg = array(isset($node->nid) ? $node->nid : $node->type);
|
||||
$output = ctools_context_handler_render($task, '', $contexts, $arg);
|
||||
if ($output === FALSE) {
|
||||
// Fall back!
|
||||
// We've already built the form with the context, so we can't build it again, or
|
||||
// form_clean_id will mess up our ids. But we don't really need to, either:
|
||||
$context = reset($contexts);
|
||||
$output = $context->form;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to handle the process of adding a node.
|
||||
*
|
||||
* This creates a basic $node and passes that off to page_manager_node_edit().
|
||||
* It is modeled after Drupal's node_add() function.
|
||||
*
|
||||
* Unlike node_add() we do not need to check node_access because that was
|
||||
* already checked by the menu system.
|
||||
*/
|
||||
function page_manager_node_add($type) {
|
||||
global $user;
|
||||
|
||||
$types = node_type_get_types();
|
||||
|
||||
// Initialize settings:
|
||||
$node = (object) array(
|
||||
'uid' => $user->uid,
|
||||
'name' => (isset($user->name) ? $user->name : ''),
|
||||
'type' => $type,
|
||||
'language' => LANGUAGE_NONE,
|
||||
);
|
||||
|
||||
drupal_set_title(t('Create @name', array('@name' => $types[$type]->name)));
|
||||
return page_manager_node_edit($node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get arguments provided by this task handler.
|
||||
*
|
||||
* Since this is the node edit and there is no UI on the arguments, we
|
||||
* create dummy arguments that contain the needed data.
|
||||
*/
|
||||
function page_manager_node_edit_get_arguments($task, $subtask_id) {
|
||||
return array(
|
||||
array(
|
||||
'keyword' => 'node',
|
||||
'identifier' => t('Node being edited'),
|
||||
'id' => 1,
|
||||
'name' => 'node_edit',
|
||||
'settings' => array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get context placeholders provided by this handler.
|
||||
*/
|
||||
function page_manager_node_edit_get_contexts($task, $subtask_id) {
|
||||
return ctools_context_get_placeholders_from_argument(page_manager_node_edit_get_arguments($task, $subtask_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to enable/disable the page from the UI.
|
||||
*/
|
||||
function page_manager_node_edit_enable($cache, $status) {
|
||||
variable_set('page_manager_node_edit_disabled', $status);
|
||||
// Set a global flag so that the menu routine knows it needs
|
||||
// to set a message if enabling cannot be done.
|
||||
if (!$status) {
|
||||
$GLOBALS['page_manager_enabling_node_edit'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine if a page is accessible.
|
||||
*
|
||||
* @param $task
|
||||
* The task plugin.
|
||||
* @param $subtask_id
|
||||
* The subtask id
|
||||
* @param $contexts
|
||||
* The contexts loaded for the task.
|
||||
* @return
|
||||
* TRUE if the current user can access the page.
|
||||
*/
|
||||
function page_manager_node_edit_access_check($task, $subtask_id, $contexts) {
|
||||
$context = reset($contexts);
|
||||
return node_access('update', $context->data);
|
||||
}
|
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Handle the 'node view' override task.
|
||||
*
|
||||
* This plugin overrides node/%node and reroutes it to the page manager, where
|
||||
* a list of tasks can be used to service this request based upon criteria
|
||||
* supplied by access plugins.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
|
||||
* more information.
|
||||
*/
|
||||
function page_manager_node_view_page_manager_tasks() {
|
||||
return array(
|
||||
// This is a 'page' task and will fall under the page admin UI
|
||||
'task type' => 'page',
|
||||
|
||||
'title' => t('Node template'),
|
||||
|
||||
'admin title' => t('Node template'),
|
||||
'admin description' => t('When enabled, this overrides the default Drupal behavior for displaying nodes at <em>node/%node</em>. If you add variants, you may use selection criteria such as node type or language or user access to provide different views of nodes. If no variant is selected, the default Drupal node view will be used. This page only affects nodes viewed as pages, it will not affect nodes viewed in lists or at other locations. Also please note that if you are using pathauto, aliases may make a node to be somewhere else, but as far as Drupal is concerned, they are still at node/%node.'),
|
||||
'admin path' => 'node/%node',
|
||||
|
||||
// Menu hooks so that we can alter the node/%node menu entry to point to us.
|
||||
'hook menu' => 'page_manager_node_view_menu',
|
||||
'hook menu alter' => 'page_manager_node_view_menu_alter',
|
||||
|
||||
// This is task uses 'context' handlers and must implement these to give the
|
||||
// handler data it needs.
|
||||
'handler type' => 'context',
|
||||
'get arguments' => 'page_manager_node_view_get_arguments',
|
||||
'get context placeholders' => 'page_manager_node_view_get_contexts',
|
||||
|
||||
// Allow this to be enabled or disabled:
|
||||
'disabled' => variable_get('page_manager_node_view_disabled', TRUE),
|
||||
'enable callback' => 'page_manager_node_view_enable',
|
||||
'access callback' => 'page_manager_node_view_access_check',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback defined by page_manager_node_view_page_manager_tasks().
|
||||
*
|
||||
* Alter the node view input so that node view comes to us rather than the
|
||||
* normal node view process.
|
||||
*/
|
||||
function page_manager_node_view_menu_alter(&$items, $task) {
|
||||
if (variable_get('page_manager_node_view_disabled', TRUE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Override the node view handler for our purpose.
|
||||
$callback = $items['node/%node']['page callback'];
|
||||
if ($callback == 'node_page_view' || variable_get('page_manager_override_anyway', FALSE)) {
|
||||
$items['node/%node']['page callback'] = 'page_manager_node_view_page';
|
||||
$items['node/%node']['file path'] = $task['path'];
|
||||
$items['node/%node']['file'] = $task['file'];
|
||||
}
|
||||
else {
|
||||
// automatically disable this task if it cannot be enabled.
|
||||
variable_set('page_manager_node_view_disabled', TRUE);
|
||||
if (!empty($GLOBALS['page_manager_enabling_node_view'])) {
|
||||
drupal_set_message(t('Page manager module is unable to enable node/%node because some other module already has overridden with %callback.', array('%callback' => $callback)), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// @todo override node revision handler as well?
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for our overridden node view.
|
||||
*
|
||||
* This function asks its assigned handlers who, if anyone, would like
|
||||
* to run with it. If no one does, it passes through to Drupal core's
|
||||
* node view, which is node_page_view().
|
||||
*/
|
||||
function page_manager_node_view_page($node) {
|
||||
// Load my task plugin
|
||||
$task = page_manager_get_task('node_view');
|
||||
|
||||
// Load the node into a context.
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
|
||||
// We need to mimic Drupal's behavior of setting the node title here.
|
||||
drupal_set_title($node->title);
|
||||
$uri = entity_uri('node', $node);
|
||||
// Set the node path as the canonical URL to prevent duplicate content.
|
||||
drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);
|
||||
// Set the non-aliased path as a default shortlink.
|
||||
drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE);
|
||||
$contexts = ctools_context_handler_get_task_contexts($task, '', array($node));
|
||||
|
||||
$output = ctools_context_handler_render($task, '', $contexts, array($node->nid));
|
||||
if ($output != FALSE) {
|
||||
node_tag_new($node);
|
||||
return $output;
|
||||
}
|
||||
|
||||
$function = 'node_page_view';
|
||||
foreach (module_implements('page_manager_override') as $module) {
|
||||
$call = $module . '_page_manager_override';
|
||||
if (($rc = $call('node_view')) && function_exists($rc)) {
|
||||
$function = $rc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, fall back.
|
||||
return $function($node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get arguments provided by this task handler.
|
||||
*
|
||||
* Since this is the node view and there is no UI on the arguments, we
|
||||
* create dummy arguments that contain the needed data.
|
||||
*/
|
||||
function page_manager_node_view_get_arguments($task, $subtask_id) {
|
||||
return array(
|
||||
array(
|
||||
'keyword' => 'node',
|
||||
'identifier' => t('Node being viewed'),
|
||||
'id' => 1,
|
||||
'name' => 'entity_id:node',
|
||||
'settings' => array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get context placeholders provided by this handler.
|
||||
*/
|
||||
function page_manager_node_view_get_contexts($task, $subtask_id) {
|
||||
return ctools_context_get_placeholders_from_argument(page_manager_node_view_get_arguments($task, $subtask_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to enable/disable the page from the UI.
|
||||
*/
|
||||
function page_manager_node_view_enable($cache, $status) {
|
||||
variable_set('page_manager_node_view_disabled', $status);
|
||||
|
||||
// Set a global flag so that the menu routine knows it needs
|
||||
// to set a message if enabling cannot be done.
|
||||
if (!$status) {
|
||||
$GLOBALS['page_manager_enabling_node_view'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine if a page is accessible.
|
||||
*
|
||||
* @param $task
|
||||
* The task plugin.
|
||||
* @param $subtask_id
|
||||
* The subtask id
|
||||
* @param $contexts
|
||||
* The contexts loaded for the task.
|
||||
* @return
|
||||
* TRUE if the current user can access the page.
|
||||
*/
|
||||
function page_manager_node_view_access_check($task, $subtask_id, $contexts) {
|
||||
$context = reset($contexts);
|
||||
return node_access('view', $context->data);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,787 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Handle the 'page' task, which creates pages with arbitrary tasks and lets
|
||||
* handlers decide how they will be rendered.
|
||||
*
|
||||
* This creates subtasks and stores them in the page_manager_pages table. These
|
||||
* are exportable objects, too.
|
||||
*
|
||||
* The render callback for this task type has $handler, $page, $contexts as
|
||||
* parameters.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
|
||||
* more information.
|
||||
*/
|
||||
function page_manager_page_page_manager_tasks() {
|
||||
return array(
|
||||
'title' => t('Custom pages'),
|
||||
'description' => t('Administrator created pages that have a URL path, access control and entries in the Drupal menu system.'),
|
||||
'non-exportable' => TRUE,
|
||||
'subtasks' => TRUE,
|
||||
'subtask callback' => 'page_manager_page_subtask',
|
||||
'subtasks callback' => 'page_manager_page_subtasks',
|
||||
'save subtask callback' => 'page_manager_page_save_subtask',
|
||||
'access callback' => 'page_manager_page_access_check',
|
||||
'hook menu' => array(
|
||||
'file' => 'page.admin.inc',
|
||||
'path' => drupal_get_path('module', 'page_manager') . '/plugins/tasks',
|
||||
'function' => 'page_manager_page_menu',
|
||||
),
|
||||
'hook theme' => 'page_manager_page_theme',
|
||||
// page only items
|
||||
'task type' => 'page',
|
||||
'page operations' => array(
|
||||
array(
|
||||
'title' => ' » ' . t('Create a new page'),
|
||||
'href' => 'admin/structure/pages/add',
|
||||
'html' => TRUE,
|
||||
),
|
||||
),
|
||||
'columns' => array(
|
||||
'storage' => array(
|
||||
'label' => t('Storage'),
|
||||
'class' => 'page-manager-page-storage',
|
||||
),
|
||||
),
|
||||
'page type' => 'custom',
|
||||
|
||||
// context only items
|
||||
'handler type' => 'context',
|
||||
'get arguments' => array(
|
||||
'file' => 'page.admin.inc',
|
||||
'path' => drupal_get_path('module', 'page_manager') . '/plugins/tasks',
|
||||
'function' => 'page_manager_page_get_arguments',
|
||||
),
|
||||
'get context placeholders' => 'page_manager_page_get_contexts',
|
||||
'access restrictions' => 'page_manager_page_access_restrictions',
|
||||
'uses handlers' => TRUE,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Task callback to get all subtasks.
|
||||
*
|
||||
* Return a list of all subtasks.
|
||||
*/
|
||||
function page_manager_page_subtasks($task) {
|
||||
$pages = page_manager_page_load_all($task['name']);
|
||||
$return = array();
|
||||
foreach ($pages as $name => $page) {
|
||||
$return[$name] = page_manager_page_build_subtask($task, $page);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to return a single subtask.
|
||||
*/
|
||||
function page_manager_page_subtask($task, $subtask_id) {
|
||||
$page = page_manager_page_load($subtask_id);
|
||||
if ($page) {
|
||||
return page_manager_page_build_subtask($task, $page);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call back from the administrative system to save a page.
|
||||
*
|
||||
* We get the $subtask as created by page_manager_page_build_subtask.
|
||||
*/
|
||||
function page_manager_page_save_subtask($subtask) {
|
||||
$page = &$subtask['subtask'];
|
||||
|
||||
// Ensure $page->arguments contains only real arguments:
|
||||
$arguments = page_manager_page_get_named_arguments($page->path);
|
||||
$args = array();
|
||||
foreach ($arguments as $keyword => $position) {
|
||||
if (isset($page->arguments[$keyword])) {
|
||||
$args[$keyword] = $page->arguments[$keyword];
|
||||
}
|
||||
else {
|
||||
$args[$keyword] = array(
|
||||
'id' => '',
|
||||
'identifier' => '',
|
||||
'argument' => '',
|
||||
'settings' => array(),
|
||||
);
|
||||
}
|
||||
}
|
||||
page_manager_page_recalculate_arguments($page);
|
||||
// Create a real object from the cache
|
||||
page_manager_page_save($page);
|
||||
|
||||
// Check to see if we should make this the site frontpage.
|
||||
if (!empty($page->make_frontpage)) {
|
||||
$path = array();
|
||||
foreach (explode('/', $page->path) as $bit) {
|
||||
if ($bit[0] != '!') {
|
||||
$path[] = $bit;
|
||||
}
|
||||
}
|
||||
|
||||
$path = implode('/', $path);
|
||||
$front = variable_get('site_frontpage', 'node');
|
||||
if ($path != $front) {
|
||||
variable_set('site_frontpage', $path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a subtask array for a given page.
|
||||
*/
|
||||
function page_manager_page_build_subtask($task, $page) {
|
||||
$operations = array();
|
||||
$operations['settings'] = array(
|
||||
'type' => 'group',
|
||||
'class' => array('operations-settings'),
|
||||
'title' => t('Settings'),
|
||||
'children' => array(),
|
||||
);
|
||||
|
||||
$settings = &$operations['settings']['children'];
|
||||
|
||||
$settings['basic'] = array(
|
||||
'title' => t('Basic'),
|
||||
'description' => t('Edit name, path and other basic settings for the page.'),
|
||||
'form' => 'page_manager_page_form_basic',
|
||||
);
|
||||
|
||||
$arguments = page_manager_page_get_named_arguments($page->path);
|
||||
if ($arguments) {
|
||||
$settings['argument'] = array(
|
||||
'title' => t('Arguments'),
|
||||
'description' => t('Set up contexts for the arguments on this page.'),
|
||||
'form' => 'page_manager_page_form_argument',
|
||||
);
|
||||
}
|
||||
|
||||
$settings['access'] = array(
|
||||
'title' => t('Access'),
|
||||
'description' => t('Control what users can access this page.'),
|
||||
'admin description' => t('Access rules are used to test if the page is accessible and any menu items associated with it are visible.'),
|
||||
'form' => 'page_manager_page_form_access',
|
||||
);
|
||||
|
||||
$settings['menu'] = array(
|
||||
'title' => t('Menu'),
|
||||
'description' => t('Provide this page a visible menu or a menu tab.'),
|
||||
'form' => 'page_manager_page_form_menu',
|
||||
);
|
||||
|
||||
$operations['actions']['children']['clone'] = array(
|
||||
'title' => t('Clone'),
|
||||
'description' => t('Make a copy of this page'),
|
||||
'form' => 'page_manager_page_form_clone',
|
||||
);
|
||||
$operations['actions']['children']['export'] = array(
|
||||
'title' => t('Export'),
|
||||
'description' => t('Export this page as code that can be imported or embedded into a module.'),
|
||||
'form' => 'page_manager_page_form_export',
|
||||
);
|
||||
if ($page->export_type == (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) {
|
||||
$operations['actions']['children']['delete'] = array(
|
||||
'title' => t('Revert'),
|
||||
'description' => t('Remove all changes to this page and revert to the version in code.'),
|
||||
'form' => 'page_manager_page_form_delete',
|
||||
);
|
||||
}
|
||||
else if ($page->export_type != EXPORT_IN_CODE) {
|
||||
$operations['actions']['children']['delete'] = array(
|
||||
'title' => t('Delete'),
|
||||
'description' => t('Remove this page from your system completely.'),
|
||||
'form' => 'page_manager_page_form_delete',
|
||||
);
|
||||
}
|
||||
|
||||
$subtask = array(
|
||||
'name' => $page->name,
|
||||
'admin title' => check_plain($page->admin_title),
|
||||
'admin description' => filter_xss_admin($page->admin_description),
|
||||
'admin summary' => 'page_manager_page_admin_summary',
|
||||
'admin path' => $page->path,
|
||||
'admin type' => t('Custom'),
|
||||
'subtask' => $page,
|
||||
'operations' => $operations,
|
||||
'operations include' => array(
|
||||
'file' => 'page.admin.inc',
|
||||
'path' => drupal_get_path('module', 'page_manager') . '/plugins/tasks',
|
||||
),
|
||||
'single task' => empty($page->multiple),
|
||||
'row class' => empty($page->disabled) ? 'page-manager-enabled' : 'page-manager-disabled',
|
||||
'storage' => $page->type == t('Default') ? t('In code') : $page->type,
|
||||
'disabled' => !empty($page->disabled),
|
||||
// This works for both enable AND disable
|
||||
'enable callback' => 'page_manager_page_enable',
|
||||
);
|
||||
|
||||
// default handlers may appear from a default subtask.
|
||||
if (isset($page->default_handlers)) {
|
||||
$subtask['default handlers'] = $page->default_handlers;
|
||||
}
|
||||
return $subtask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegated implementation of hook_theme().
|
||||
*/
|
||||
function page_manager_page_theme(&$items, $task) {
|
||||
$base = array(
|
||||
'file' => 'page.admin.inc',
|
||||
'path' => drupal_get_path('module', 'page_manager') . '/plugins/tasks',
|
||||
);
|
||||
$items['page_manager_page_form_argument_table'] = $base + array(
|
||||
'render element' => 'form',
|
||||
);
|
||||
$items['page_manager_page_lock'] = $base + array(
|
||||
'variables' => array('lock' => array(), 'task_name' => NULL),
|
||||
);
|
||||
$items['page_manager_page_changed'] = $base + array(
|
||||
'variables' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Page execution functions
|
||||
|
||||
/**
|
||||
* Execute a page task.
|
||||
*
|
||||
* This is the callback to entries in the Drupal menu system created by the
|
||||
* page task.
|
||||
*
|
||||
* @param $subtask_id
|
||||
* The name of the page task used.
|
||||
* @param ...
|
||||
* A number of context objects as specified by the user when
|
||||
* creating named arguments in the path.
|
||||
*/
|
||||
function page_manager_page_execute($subtask_id) {
|
||||
$page = page_manager_page_load($subtask_id);
|
||||
$task = page_manager_get_task($page->task);
|
||||
$subtask = page_manager_get_task_subtask($task, $subtask_id);
|
||||
|
||||
// Turn the contexts into a properly keyed array.
|
||||
$contexts = array();
|
||||
$args = array();
|
||||
foreach (func_get_args() as $count => $arg) {
|
||||
if (is_object($arg) && get_class($arg) == 'ctools_context') {
|
||||
$contexts[$arg->id] = $arg;
|
||||
$args[] = $arg->original_argument;
|
||||
}
|
||||
else if ($count) {
|
||||
$args[] = $arg;
|
||||
}
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
$names = page_manager_page_get_named_arguments($page->path);
|
||||
$bits = explode('/', $page->path);
|
||||
|
||||
if ($page->arguments) {
|
||||
foreach ($page->arguments as $name => $argument) {
|
||||
// Optional arguments must be converted to contexts too, if they exist.
|
||||
if ($bits[$names[$name]][0] == '!') {
|
||||
ctools_include('context');
|
||||
$argument['keyword'] = $name;
|
||||
if (isset($args[$count])) {
|
||||
// Hack: use a special argument config variable to learn if we need
|
||||
// to use menu_tail style behavior:
|
||||
if (empty($argument['settings']['use_tail'])) {
|
||||
$value = $args[$count];
|
||||
}
|
||||
else {
|
||||
$value = implode('/', array_slice($args, $count));
|
||||
}
|
||||
|
||||
$context = ctools_context_get_context_from_argument($argument, $value);
|
||||
}
|
||||
else {
|
||||
// make sure there is a placeholder context for missing optional contexts.
|
||||
$context = ctools_context_get_context_from_argument($argument, NULL, TRUE);
|
||||
// Force the title to blank for replacements
|
||||
}
|
||||
if ($context) {
|
||||
$contexts[$context->id] = $context;
|
||||
}
|
||||
}
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($function = ctools_plugin_get_function($task, 'page callback')) {
|
||||
return call_user_func_array($function, array($page, $contexts, $args));
|
||||
}
|
||||
|
||||
ctools_include('context-task-handler');
|
||||
$output = ctools_context_handler_render($task, $subtask, $contexts, $args);
|
||||
if ($output === FALSE) {
|
||||
return drupal_not_found();
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Context type callbacks
|
||||
|
||||
/**
|
||||
* Return a list of arguments used by this task.
|
||||
*/
|
||||
function page_manager_page_get_arguments($task, $subtask) {
|
||||
return _page_manager_page_get_arguments($subtask['subtask']);
|
||||
}
|
||||
|
||||
function _page_manager_page_get_arguments($page) {
|
||||
$arguments = array();
|
||||
if (!empty($page->arguments)) {
|
||||
foreach ($page->arguments as $keyword => $argument) {
|
||||
if (isset($argument['name'])) {
|
||||
$argument['keyword'] = $keyword;
|
||||
$arguments[$keyword] = $argument;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a group of context placeholders for the arguments.
|
||||
*/
|
||||
function page_manager_page_get_contexts($task, $subtask) {
|
||||
ctools_include('context');
|
||||
return ctools_context_get_placeholders_from_argument(page_manager_page_get_arguments($task, $subtask));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of arguments used by this task.
|
||||
*/
|
||||
function page_manager_page_access_restrictions($task, $subtask, $contexts) {
|
||||
$page = $subtask['subtask'];
|
||||
return ctools_access_add_restrictions($page->access, $contexts);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
// Page task database info.
|
||||
|
||||
/**
|
||||
* Create a new page with defaults appropriately set from schema.
|
||||
*/
|
||||
function page_manager_page_new() {
|
||||
ctools_include('export');
|
||||
return ctools_export_new_object('page_manager_pages');
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a single page subtask.
|
||||
*/
|
||||
function page_manager_page_load($name) {
|
||||
ctools_include('export');
|
||||
$result = ctools_export_load_object('page_manager_pages', 'names', array($name));
|
||||
if (isset($result[$name])) {
|
||||
return $result[$name];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all page subtasks.
|
||||
*/
|
||||
function page_manager_page_load_all($task = NULL) {
|
||||
ctools_include('export');
|
||||
|
||||
if (empty($task)) {
|
||||
return ctools_export_load_object('page_manager_pages');
|
||||
}
|
||||
else {
|
||||
return ctools_export_load_object('page_manager_pages', 'conditions', array('task' => $task));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a page subtask to the database.
|
||||
*/
|
||||
function page_manager_page_save(&$page) {
|
||||
$update = (isset($page->pid)) ? array('pid') : array();
|
||||
$task = page_manager_get_task($page->task);
|
||||
|
||||
if ($function = ctools_plugin_get_function($task, 'save')) {
|
||||
$function($page, $update);
|
||||
}
|
||||
drupal_write_record('page_manager_pages', $page, $update);
|
||||
|
||||
// If this was a default page we may need to write default task
|
||||
// handlers that we provided as well.
|
||||
if (!$update && isset($page->default_handlers)) {
|
||||
$handlers = page_manager_load_task_handlers(page_manager_get_task('page'), $page->name);
|
||||
foreach ($page->default_handlers as $name => $handler) {
|
||||
if (!isset($handlers[$name]) || !($handlers[$name]->export_type & EXPORT_IN_DATABASE)) {
|
||||
// Make sure this is right, as exports can wander a bit.
|
||||
$handler->subtask = $page->name;
|
||||
page_manager_save_task_handler($handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a page subtask.
|
||||
*/
|
||||
function page_manager_page_delete($page) {
|
||||
$task = page_manager_get_task($page->task);
|
||||
if ($function = ctools_plugin_get_function($task, 'delete')) {
|
||||
$function($page);
|
||||
}
|
||||
if (!empty($task['uses handlers'])) {
|
||||
$handlers = page_manager_load_task_handlers($task, $page->name);
|
||||
foreach ($handlers as $handler) {
|
||||
page_manager_delete_task_handler($handler);
|
||||
}
|
||||
}
|
||||
db_delete('page_manager_pages')
|
||||
->condition('name', $page->name)
|
||||
->execute();
|
||||
// Make sure that the cache is reset so that the menu rebuild does not
|
||||
// rebuild this page again.
|
||||
ctools_include('export');
|
||||
ctools_export_load_object_reset('page_manager_pages');
|
||||
menu_rebuild();
|
||||
}
|
||||
|
||||
/**
|
||||
* Export a page subtask.
|
||||
*/
|
||||
function page_manager_page_export($page, $with_handlers = FALSE, $indent = '') {
|
||||
$task = page_manager_get_task($page->task);
|
||||
$append = '';
|
||||
|
||||
if ($function = ctools_plugin_get_function($task, 'export')) {
|
||||
$append = $function($page, $indent);
|
||||
}
|
||||
|
||||
ctools_include('export');
|
||||
$output = ctools_export_object('page_manager_pages', $page, $indent);
|
||||
$output .= $append;
|
||||
|
||||
if ($with_handlers) {
|
||||
if (is_array($with_handlers)) {
|
||||
$handlers = $with_handlers;
|
||||
}
|
||||
else {
|
||||
$handlers = page_manager_load_task_handlers(page_manager_get_task('page'), $page->name);
|
||||
}
|
||||
$output .= $indent . '$page->default_handlers = array();' . "\n";
|
||||
foreach ($handlers as $handler) {
|
||||
$output .= page_manager_export_task_handler($handler, $indent);
|
||||
$output .= $indent . '$page->default_handlers[$handler->name] = $handler;' . "\n";
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of named arguments in a page manager path.
|
||||
*
|
||||
* @param $path
|
||||
* A normal Drupal path.
|
||||
*
|
||||
* @return
|
||||
* An array of % marked variable arguments, keyed by the argument's name.
|
||||
* The value will be the position of the argument so that it can easily
|
||||
* be found. Items with a position of -1 have multiple positions.
|
||||
*/
|
||||
function page_manager_page_get_named_arguments($path) {
|
||||
$arguments = array();
|
||||
$bits = explode('/', $path);
|
||||
foreach ($bits as $position => $bit) {
|
||||
if ($bit && ($bit[0] == '%' || $bit[0] == '!')) {
|
||||
// special handling for duplicate path items and substr to remove the %
|
||||
$arguments[substr($bit, 1)] = isset($arguments[$bit]) ? -1 : $position;
|
||||
}
|
||||
}
|
||||
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a context from an argument for a given page task.
|
||||
*
|
||||
* Helper function for pm_arg_load(), which is in page_manager.module because
|
||||
* drupal's menu system does not allow loader functions to reside in separate
|
||||
* files.
|
||||
*
|
||||
* @param $value
|
||||
* The incoming argument value.
|
||||
* @param $subtask
|
||||
* The subtask id.
|
||||
* @param $argument
|
||||
* The numeric position of the argument in the path, counting from 0.
|
||||
*
|
||||
* @return
|
||||
* A context item if one is configured, the argument if one is not, or
|
||||
* FALSE if restricted or invalid.
|
||||
*/
|
||||
function _pm_arg_load($value, $subtask, $argument) {
|
||||
$page = page_manager_page_load($subtask);
|
||||
if (!$page) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$path = explode('/', $page->path);
|
||||
if (empty($path[$argument])) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$keyword = substr($path[$argument], 1);
|
||||
if (empty($page->arguments[$keyword])) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$page->arguments[$keyword]['keyword'] = $keyword;
|
||||
|
||||
ctools_include('context');
|
||||
$context = ctools_context_get_context_from_argument($page->arguments[$keyword], $value);
|
||||
|
||||
// convert false equivalents to false.
|
||||
return $context ? $context : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a nice administrative summary of the page so an admin can see at a
|
||||
* glance what this page does and how it is configured.
|
||||
*/
|
||||
function page_manager_page_admin_summary($task, $subtask) {
|
||||
$task_name = page_manager_make_task_name($task['name'], $subtask['name']);
|
||||
$page = $subtask['subtask'];
|
||||
$output = '';
|
||||
|
||||
$rows = array();
|
||||
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-label'), 'data' => t('Storage')),
|
||||
array('class' => array('page-summary-data'), 'data' => $subtask['storage']),
|
||||
array('class' => array('page-summary-operation'), 'data' => ''),
|
||||
);
|
||||
|
||||
if (!empty($page->disabled)) {
|
||||
$link = l(t('Enable'), page_manager_edit_url($task_name, array('handlers', $page->name, 'actions', 'enable')));
|
||||
$text = t('Disabled');
|
||||
}
|
||||
else {
|
||||
$link = l(t('Disable'), page_manager_edit_url($task_name, array('handlers', $page->name, 'actions', 'disable')));
|
||||
$text = t('Enabled');
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-label'), 'data' => t('Status')),
|
||||
array('class' => array('page-summary-data'), 'data' => $text),
|
||||
array('class' => array('page-summary-operation'), 'data' => $link),
|
||||
);
|
||||
|
||||
|
||||
$path = array();
|
||||
foreach (explode('/', $page->path) as $bit) {
|
||||
if ($bit[0] != '!') {
|
||||
$path[] = $bit;
|
||||
}
|
||||
}
|
||||
|
||||
$path = implode('/', $path);
|
||||
$front = variable_get('site_frontpage', 'node');
|
||||
|
||||
$link = l(t('Edit'), page_manager_edit_url($task_name, array('settings', 'basic')));
|
||||
$message = '';
|
||||
if ($path == $front) {
|
||||
$message = t('This is your site home page.');
|
||||
}
|
||||
else if (!empty($page->make_frontpage)) {
|
||||
$message = t('This page is set to become your site home page.');
|
||||
}
|
||||
|
||||
if ($message) {
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-data'), 'data' => $message, 'colspan' => 2),
|
||||
array('class' => array('page-summary-operation'), 'data' => $link),
|
||||
);
|
||||
}
|
||||
|
||||
if (strpos($path, '%') === FALSE) {
|
||||
$path = l('/' . $page->path, $path);
|
||||
}
|
||||
else {
|
||||
$path = '/' . $page->path;
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-label'), 'data' => t('Path')),
|
||||
array('class' => array('page-summary-data'), 'data' => $path),
|
||||
array('class' => array('page-summary-operation'), 'data' => $link),
|
||||
);
|
||||
|
||||
if (empty($access['plugins'])) {
|
||||
$access['plugins'] = array();
|
||||
}
|
||||
|
||||
$contexts = page_manager_page_get_contexts($task, $subtask);
|
||||
$access = ctools_access_group_summary($page->access, $contexts);
|
||||
if ($access) {
|
||||
$access = t('Accessible only if @conditions.', array('@conditions' => $access));
|
||||
}
|
||||
else {
|
||||
$access = t('This page is publicly accessible.');
|
||||
}
|
||||
|
||||
$link = l(t('Edit'), page_manager_edit_url($task_name, array('settings', 'access')));
|
||||
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-label'), 'data' => t('Access')),
|
||||
array('class' => array('page-summary-data'), 'data' => $access),
|
||||
array('class' => array('page-summary-operation'), 'data' => $link),
|
||||
);
|
||||
|
||||
$menu_options = array(
|
||||
'none' => t('No menu entry.'),
|
||||
'normal' => t('Normal menu entry.'),
|
||||
'tab' => t('Menu tab.'),
|
||||
'default tab' => t('Default menu tab.'),
|
||||
'action' => t('Local action'),
|
||||
);
|
||||
|
||||
if (!empty($page->menu)) {
|
||||
$menu = $menu_options[$page->menu['type']];
|
||||
if ($page->menu['type'] != 'none') {
|
||||
$menu .= ' ' . t('Title: %title.', array('%title' => $page->menu['title']));
|
||||
switch ($page->menu['type']) {
|
||||
case 'default tab':
|
||||
$menu .= ' ' . t('Parent title: %title.', array('%title' => $page->menu['parent']['title']));
|
||||
break;
|
||||
case 'normal':
|
||||
if (module_exists('menu')) {
|
||||
$menus = menu_get_menus();
|
||||
$menu .= ' ' . t('Menu block: %title.', array('%title' => $menus[$page->menu['name']]));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$menu = t('No menu entry');
|
||||
}
|
||||
|
||||
$link = l(t('Edit'), page_manager_edit_url($task_name, array('settings', 'menu')));
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-label'), 'data' => t('Menu')),
|
||||
array('class' => array('page-summary-data'), 'data' => $menu),
|
||||
array('class' => array('page-summary-operation'), 'data' => $link),
|
||||
);
|
||||
|
||||
$output .= theme('table', array('rows' => $rows, 'attributes' => array('id' => 'page-manager-page-summary')));
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to enable/disable the page from the UI.
|
||||
*/
|
||||
function page_manager_page_enable(&$cache, $status) {
|
||||
$page = &$cache->subtask['subtask'];
|
||||
ctools_include('export');
|
||||
ctools_export_set_object_status($page, $status);
|
||||
|
||||
$page->disabled = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculate the arguments when something like the path changes.
|
||||
*/
|
||||
function page_manager_page_recalculate_arguments(&$page) {
|
||||
// Ensure $page->arguments contains only real arguments:
|
||||
$arguments = page_manager_page_get_named_arguments($page->path);
|
||||
$args = array();
|
||||
foreach ($arguments as $keyword => $position) {
|
||||
if (isset($page->arguments[$keyword])) {
|
||||
$args[$keyword] = $page->arguments[$keyword];
|
||||
}
|
||||
else {
|
||||
$args[$keyword] = array(
|
||||
'id' => '',
|
||||
'identifier' => '',
|
||||
'argument' => '',
|
||||
'settings' => array(),
|
||||
);
|
||||
}
|
||||
}
|
||||
$page->arguments = $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* When adding or cloning a new page, this creates a new page cache
|
||||
* and adds our page to it.
|
||||
*
|
||||
* This does not check to see if the existing cache is already locked.
|
||||
* This must be done beforehand.
|
||||
*
|
||||
* @param &$page
|
||||
* The page to create.
|
||||
* @param &$cache
|
||||
* The cache to use. If the cache has any existing task handlers,
|
||||
* they will be marked for deletion. This may be a blank object.
|
||||
*/
|
||||
function page_manager_page_new_page_cache(&$page, &$cache) {
|
||||
// Does a page already exist? If so, we are overwriting it so
|
||||
// take its pid.
|
||||
if (!empty($cache->subtask) && !empty($cache->subtask['subtask']) && !empty($cache->subtask['subtask']->pid)) {
|
||||
$page->pid = $cache->subtask['subtask']->pid;
|
||||
}
|
||||
else {
|
||||
$cache->new = TRUE;
|
||||
}
|
||||
|
||||
$cache->task_name = page_manager_make_task_name('page', $page->name);
|
||||
$cache->task_id = 'page';
|
||||
$cache->task = page_manager_get_task('page');
|
||||
$cache->subtask_id = $page->name;
|
||||
$page->export_type = EXPORT_IN_DATABASE;
|
||||
$page->type = t('Normal');
|
||||
$cache->subtask = page_manager_page_build_subtask($cache->task, $page);
|
||||
|
||||
if (isset($cache->handlers)) {
|
||||
foreach($cache->handlers as $id => $handler) {
|
||||
$cache->handler_info[$id]['changed'] = PAGE_MANAGER_CHANGED_DELETED;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$cache->handlers = array();
|
||||
$cache->handler_info = array();
|
||||
}
|
||||
|
||||
if (!empty($page->default_handlers)) {
|
||||
foreach ($page->default_handlers as $id => $handler) {
|
||||
page_manager_handler_add_to_page($cache, $handler);
|
||||
}
|
||||
}
|
||||
|
||||
$cache->locked = FALSE;
|
||||
$cache->changed = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine if a page is accessible.
|
||||
*
|
||||
* @param $task
|
||||
* The task plugin.
|
||||
* @param $subtask_id
|
||||
* The subtask id
|
||||
* @param $contexts
|
||||
* The contexts loaded for the task.
|
||||
* @return
|
||||
* TRUE if the current user can access the page.
|
||||
*/
|
||||
function page_manager_page_access_check($task, $subtask_id, $contexts) {
|
||||
$page = page_manager_page_load($subtask_id);
|
||||
return ctools_access($page->access, $contexts);
|
||||
}
|
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
|
||||
* more information.
|
||||
*/
|
||||
function page_manager_poll_page_manager_tasks() {
|
||||
if (!module_exists('poll')) {
|
||||
return;
|
||||
}
|
||||
|
||||
return array(
|
||||
// This is a 'page' task and will fall under the page admin UI
|
||||
'task type' => 'page',
|
||||
|
||||
'title' => t('All polls'),
|
||||
'admin title' => t('All polls'),
|
||||
'admin description' => t('When enabled, this overrides the default Drupal behavior for the polls at <em>/poll</em>. If no variant is selected, the default Drupal most recent polls will be shown.'),
|
||||
'admin path' => 'poll',
|
||||
|
||||
// Menu hooks so that we can alter the node/%node menu entry to point to us.
|
||||
'hook menu alter' => 'page_manager_poll_menu_alter',
|
||||
|
||||
// This is task uses 'context' handlers and must implement these to give the
|
||||
// handler data it needs.
|
||||
'handler type' => 'context',
|
||||
|
||||
// Allow this to be enabled or disabled:
|
||||
'disabled' => variable_get('page_manager_poll_disabled', TRUE),
|
||||
'enable callback' => 'page_manager_poll_enable',
|
||||
'access callback' => 'page_manager_poll_access_check',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback defined by page_manager_poll_page_manager_tasks().
|
||||
*
|
||||
* Alter the node edit input so that node edit comes to us rather than the
|
||||
* normal node edit process.
|
||||
*/
|
||||
function page_manager_poll_menu_alter(&$items, $task) {
|
||||
if (variable_get('page_manager_poll_disabled', TRUE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$callback = $items['poll']['page callback'];
|
||||
// Override the node edit handler for our purpose.
|
||||
if ($callback == 'poll_page' || variable_get('page_manager_override_anyway', FALSE)) {
|
||||
$items['poll']['page callback'] = 'page_manager_poll';
|
||||
$items['poll']['file path'] = $task['path'];
|
||||
$items['poll']['file'] = $task['file'];
|
||||
}
|
||||
else {
|
||||
variable_set('page_manager_poll_disabled', TRUE);
|
||||
if (!empty($GLOBALS['page_manager_enabling_poll'])) {
|
||||
drupal_set_message(t('Page manager module is unable to enable poll because some other module already has overridden with %callback.', array('%callback' => $callback)), 'warning');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for our overridden node edit.
|
||||
*
|
||||
* This function asks its assigned handlers who, if anyone, would like
|
||||
* to run with it. If no one does, it passes through to Drupal core's
|
||||
* node edit, which is node_page_edit().
|
||||
*/
|
||||
function page_manager_poll() {
|
||||
// Load my task plugin
|
||||
$task = page_manager_get_task('poll');
|
||||
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
$output = ctools_context_handler_render($task, '', array(), array());
|
||||
if ($output !== FALSE) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
module_load_include('inc', 'poll', 'poll.pages');
|
||||
$function = 'poll_page';
|
||||
foreach (module_implements('page_manager_override') as $module) {
|
||||
$call = $module . '_page_manager_override';
|
||||
if (($rc = $call('poll')) && function_exists($rc)) {
|
||||
$function = $rc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, fall back.
|
||||
return $function();
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to enable/disable the page from the UI.
|
||||
*/
|
||||
function page_manager_poll_enable($cache, $status) {
|
||||
variable_set('page_manager_poll_disabled', $status);
|
||||
// Set a global flag so that the menu routine knows it needs
|
||||
// to set a message if enabling cannot be done.
|
||||
if (!$status) {
|
||||
$GLOBALS['page_manager_enabling_poll'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine if a page is accessible.
|
||||
*
|
||||
* @param $task
|
||||
* The task plugin.
|
||||
* @param $subtask_id
|
||||
* The subtask id
|
||||
* @param $contexts
|
||||
* The contexts loaded for the task.
|
||||
* @return
|
||||
* TRUE if the current user can access the page.
|
||||
*/
|
||||
function page_manager_poll_access_check($task, $subtask_id, $contexts) {
|
||||
return user_access('access content');
|
||||
}
|
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Handle the 'node view' override task.
|
||||
*
|
||||
* This plugin overrides node/%node and reroutes it to the page manager, where
|
||||
* a list of tasks can be used to service this request based upon criteria
|
||||
* supplied by access plugins.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
|
||||
* more information.
|
||||
*/
|
||||
function page_manager_search_page_manager_tasks() {
|
||||
if (!module_exists('search')) {
|
||||
return;
|
||||
}
|
||||
|
||||
return array(
|
||||
// This is a 'page' task and will fall under the page admin UI
|
||||
'task type' => 'page',
|
||||
'title' => t('Search'),
|
||||
|
||||
// There are multiple search pages, let's override each of them
|
||||
// separately.
|
||||
'subtasks' => TRUE,
|
||||
'subtask callback' => 'page_manager_search_subtask',
|
||||
'subtasks callback' => 'page_manager_search_subtasks',
|
||||
|
||||
// Menu hooks so that we can alter the node/%node menu entry to point to us.
|
||||
'hook menu alter' => 'page_manager_search_menu_alter',
|
||||
|
||||
// This is task uses 'context' handlers and must implement these to give the
|
||||
// handler data it needs.
|
||||
'handler type' => 'context',
|
||||
'get arguments' => 'page_manager_search_get_arguments',
|
||||
'get context placeholders' => 'page_manager_search_get_contexts',
|
||||
'access callback' => 'page_manager_search_access_check',
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback defined by page_manager_search_page_manager_tasks().
|
||||
*
|
||||
* Alter the search tabs to work with page manager. The search flow is
|
||||
* quite odd, and tracing through the code takes hours to realize
|
||||
* that the tab you click on does not normally actually handle
|
||||
* the search. This tries to account for that.
|
||||
*
|
||||
* Note to module authors: This tends to work a lot better with modules
|
||||
* that override their own search pages if their _alter runs *before*
|
||||
* this one.
|
||||
*/
|
||||
function page_manager_search_menu_alter(&$items, $task) {
|
||||
// We are creating two sets of tabs. One set is for searching without
|
||||
// keywords. A second set is for searching *with* keywords. This
|
||||
// is necessary because search/node/% and search/node need to be
|
||||
// different due to the way the search menu items function.
|
||||
|
||||
$default_info = search_get_default_module_info();
|
||||
if (empty($default_info)) {
|
||||
// Nothing to do.
|
||||
return;
|
||||
}
|
||||
|
||||
// Go through each search module item.
|
||||
foreach (search_get_info() as $module => $info) {
|
||||
if (variable_get('page_manager_search_disabled_' . $module, TRUE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$path = 'search/' . $info['path'];
|
||||
$callback = $items["$path/%menu_tail"]['page callback'];
|
||||
|
||||
if ($callback == 'search_view' || variable_get('page_manager_override_anyway', FALSE)) {
|
||||
$items["$path"]['page callback'] = 'page_manager_search_page';
|
||||
$items["$path"]['file path'] = $task['path'];
|
||||
$items["$path"]['file'] = $task['file'];
|
||||
|
||||
$items["$path/%menu_tail"]['page callback'] = 'page_manager_search_page';
|
||||
$items["$path/%menu_tail"]['file path'] = $task['path'];
|
||||
$items["$path/%menu_tail"]['file'] = $task['file'];
|
||||
}
|
||||
else {
|
||||
// automatically disable this task if it cannot be enabled.
|
||||
variable_set('page_manager_search_disabled_' . $module, TRUE);
|
||||
if (!empty($GLOBALS['page_manager_enabling_search'])) {
|
||||
drupal_set_message(t('Page manager module is unable to enable @path because some other module already has overridden with %callback.', array('%callback' => $callback, '@path' => $path)), 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for our overridden search page.
|
||||
*
|
||||
*/
|
||||
function page_manager_search_page($type) {
|
||||
ctools_include('menu');
|
||||
// menu_set_active_trail(ctools_get_menu_trail('search/' . $type));
|
||||
|
||||
// Get the arguments and construct a keys string out of them.
|
||||
$args = func_get_args();
|
||||
|
||||
// We have to remove the $type.
|
||||
array_shift($args);
|
||||
|
||||
// And implode() it all back together.
|
||||
$keys = $args ? implode('/', $args) : '';
|
||||
|
||||
// Allow other modules to alter the search keys
|
||||
drupal_alter(array('search_keys', 'search_'. $type .'_keys'), $keys);
|
||||
|
||||
// Load my task plugin
|
||||
$task = page_manager_get_task('search');
|
||||
$subtask = page_manager_get_task_subtask($task, $type);
|
||||
|
||||
// Load the node into a context.
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
$contexts = ctools_context_handler_get_task_contexts($task, $subtask, array($keys));
|
||||
|
||||
$output = ctools_context_handler_render($task, $subtask, $contexts, array($keys));
|
||||
if ($output !== FALSE) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
$function = 'search_view';
|
||||
foreach (module_implements('page_manager_override') as $module) {
|
||||
$call = $module . '_page_manager_override';
|
||||
if (($rc = $call('search')) && function_exists($rc)) {
|
||||
$function = $rc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, fall back.
|
||||
|
||||
// Put the $type back on the arguments.
|
||||
module_load_include('inc', 'search', 'search.pages');
|
||||
array_unshift($args, $type);
|
||||
return call_user_func_array($function, $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get arguments provided by this task handler.
|
||||
*
|
||||
* Since this is the node view and there is no UI on the arguments, we
|
||||
* create dummy arguments that contain the needed data.
|
||||
*/
|
||||
function page_manager_search_get_arguments($task, $subtask_id) {
|
||||
return array(
|
||||
array(
|
||||
'keyword' => 'keywords',
|
||||
'identifier' => t('Keywords'),
|
||||
'id' => 1,
|
||||
'name' => 'string',
|
||||
'settings' => array('use_tail' => TRUE),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get context placeholders provided by this handler.
|
||||
*/
|
||||
function page_manager_search_get_contexts($task, $subtask_id) {
|
||||
return ctools_context_get_placeholders_from_argument(page_manager_search_get_arguments($task, $subtask_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to enable/disable the page from the UI.
|
||||
*/
|
||||
function page_manager_search_enable($cache, $status) {
|
||||
variable_set('page_manager_search_disabled_' . $cache->subtask_id, $status);
|
||||
|
||||
// Set a global flag so that the menu routine knows it needs
|
||||
// to set a message if enabling cannot be done.
|
||||
if (!$status) {
|
||||
$GLOBALS['page_manager_enabling_search'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Task callback to get all subtasks.
|
||||
*
|
||||
* Return a list of all subtasks.
|
||||
*/
|
||||
function page_manager_search_subtasks($task) {
|
||||
$return = array();
|
||||
foreach (search_get_info() as $module => $info) {
|
||||
if ($info['path']) {
|
||||
// We don't pass the $info because the subtask build could be called
|
||||
// singly without the $info when just the subtask needs to be built.
|
||||
$return[$module] = page_manager_search_build_subtask($task, $module);
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to return a single subtask.
|
||||
*/
|
||||
function page_manager_search_subtask($task, $subtask_id) {
|
||||
return page_manager_search_build_subtask($task, $subtask_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a subtask array for a given page.
|
||||
*/
|
||||
function page_manager_search_build_subtask($task, $module) {
|
||||
$search_info = search_get_info();
|
||||
$info = $search_info[$module];
|
||||
$path = 'search/' . $info['path'];
|
||||
$subtask = array(
|
||||
'name' => $module,
|
||||
'admin title' => $info['title'],
|
||||
'admin path' => "$path/!keywords",
|
||||
'admin description' => t('Search @type', array('@type' => $info['title'])),
|
||||
'admin type' => t('System'),
|
||||
'row class' => empty($page->disabled) ? 'page-manager-enabled' : 'page-manager-disabled',
|
||||
'storage' => t('In code'),
|
||||
'disabled' => variable_get('page_manager_search_disabled_' . $module, TRUE),
|
||||
// This works for both enable AND disable
|
||||
'enable callback' => 'page_manager_search_enable',
|
||||
);
|
||||
|
||||
return $subtask;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine if a page is accessible.
|
||||
*
|
||||
* @param $task
|
||||
* The task plugin.
|
||||
* @param $subtask_id
|
||||
* The subtask id
|
||||
* @param $contexts
|
||||
* The contexts loaded for the task.
|
||||
* @return
|
||||
* TRUE if the current user can access the page.
|
||||
*/
|
||||
function page_manager_search_access_check($task, $subtask_id, $contexts) {
|
||||
$context = reset($contexts);
|
||||
return _search_menu_access($context->data);
|
||||
}
|
@@ -0,0 +1,377 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Handle the 'term view' override task.
|
||||
*
|
||||
* This plugin overrides term/%term and reroutes it to the page manager, where
|
||||
* a list of tasks can be used to service this request based upon criteria
|
||||
* supplied by access plugins.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
|
||||
* more information.
|
||||
*/
|
||||
function page_manager_term_view_page_manager_tasks() {
|
||||
if (module_exists('taxonomy')) {
|
||||
return array(
|
||||
// This is a 'page' task and will fall under the page admin UI
|
||||
'task type' => 'page',
|
||||
|
||||
'title' => t('Taxonomy term template'),
|
||||
'admin title' => t('Taxonomy term template'),
|
||||
'admin description' => t('When enabled, this overrides the default Drupal behavior for displaying taxonomy terms at <em>taxonomy/term/%term</em>. If you add variants, you may use selection criteria such as vocabulary or user access to provide different displays of the taxonomy term and associated nodes. If no variant is selected, the default Drupal taxonomy term display will be used. This page only affects items actually displayed ad taxonomy/term/%term. Some taxonomy terms, such as forums, have their displays moved elsewhere. Also please note that if you are using pathauto, aliases may make a taxonomy terms appear somewhere else, but as far as Drupal is concerned, they are still at taxonomy/term/%term.'),
|
||||
'admin path' => 'taxonomy/term/%taxonomy_term',
|
||||
'admin summary' => 'page_manager_term_view_admin_summary',
|
||||
|
||||
// Menu hooks so that we can alter the term/%term menu entry to point to us.
|
||||
'hook menu' => 'page_manager_term_view_menu',
|
||||
'hook menu alter' => 'page_manager_term_view_menu_alter',
|
||||
|
||||
// Provide a setting to the primary settings UI for Panels
|
||||
'admin settings' => 'page_manager_term_view_admin_settings',
|
||||
// Even though we don't have subtasks, this allows us to save our settings.
|
||||
'save subtask callback' => 'page_manager_term_view_save',
|
||||
|
||||
// Callback to add items to the page manager task administration form:
|
||||
'task admin' => 'page_manager_term_view_task_admin',
|
||||
|
||||
// This is task uses 'context' handlers and must implement these to give the
|
||||
// handler data it needs.
|
||||
'handler type' => 'context',
|
||||
'get arguments' => 'page_manager_term_view_get_arguments',
|
||||
'get context placeholders' => 'page_manager_term_view_get_contexts',
|
||||
|
||||
// Allow this to be enabled or disabled:
|
||||
'disabled' => variable_get('page_manager_term_view_disabled', TRUE),
|
||||
'enable callback' => 'page_manager_term_view_enable',
|
||||
'access callback' => 'page_manager_term_view_access_check',
|
||||
|
||||
// Allow additional operations
|
||||
'operations' => array(
|
||||
'settings' => array(
|
||||
'title' => t('Settings'),
|
||||
'description' => t('Edit name, path and other basic settings for the page.'),
|
||||
'form' => 'page_manager_term_view_settings',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback defined by page_manager_term_view_page_manager_tasks().
|
||||
*
|
||||
* Alter the term view input so that term view comes to us rather than the
|
||||
* normal term view process.
|
||||
*/
|
||||
function page_manager_term_view_menu_alter(&$items, $task) {
|
||||
if (variable_get('page_manager_term_view_disabled', TRUE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Override the term view handler for our purpose, but only if someone else
|
||||
// has not already done so.
|
||||
if (isset($items['taxonomy/term/%taxonomy_term']) && $items['taxonomy/term/%taxonomy_term']['page callback'] == 'taxonomy_term_page' || variable_get('page_manager_override_anyway', FALSE)) {
|
||||
$items['taxonomy/term/%taxonomy_term']['page callback'] = 'page_manager_term_view_page';
|
||||
$items['taxonomy/term/%taxonomy_term']['file path'] = $task['path'];
|
||||
$items['taxonomy/term/%taxonomy_term']['file'] = $task['file'];
|
||||
}
|
||||
else {
|
||||
// automatically disable this task if it cannot be enabled.
|
||||
variable_set('page_manager_term_view_disabled', TRUE);
|
||||
|
||||
if (isset($items['taxonomy/term/%taxonomy_term']['page callback'])) {
|
||||
$callback = $items['taxonomy/term/%taxonomy_term']['page callback'];
|
||||
}
|
||||
// Because Views changes %taxonomy_term to %views_arg, check to see if that
|
||||
// is why we can't enable:
|
||||
else if (isset($items['taxonomy/term/%views_arg']['page callback'])) {
|
||||
$callback = $items['taxonomy/term/%views_arg']['page callback'];
|
||||
}
|
||||
else {
|
||||
$callback = t('an unknown callback');
|
||||
}
|
||||
if (!empty($GLOBALS['page_manager_enabling_term_view'])) {
|
||||
drupal_set_message(t('Page manager module is unable to enable taxonomy/term/%taxonomy_term because some other module already has overridden with %callback.', array('%callback' => $callback)), 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for our overridden term view.
|
||||
*
|
||||
* This function asks its assigned handlers who, if anyone, would like
|
||||
* to run with it. If no one does, it passes through to Drupal core's
|
||||
* term view, which is term_page_view().
|
||||
*/
|
||||
function page_manager_term_view_page($term, $depth = NULL) {
|
||||
// Prep the term to be displayed so all of the regular hooks are triggered.
|
||||
// Rather than calling taxonomy_term_page() directly, as it that would
|
||||
// potentially load nodes that were not necessary, execute some of the code
|
||||
// prior to identifying the correct CTools or Page Manager task handler and
|
||||
// only proceed with the rest of the code if necessary.
|
||||
|
||||
// Assign the term name as the page title.
|
||||
drupal_set_title($term->name);
|
||||
|
||||
// If there is a menu link to this term, the link becomes the last part
|
||||
// of the active trail, and the link name becomes the page title.
|
||||
// Thus, we must explicitly set the page title to be the node title.
|
||||
$uri = entity_uri('taxonomy_term', $term);
|
||||
|
||||
// Set the term path as the canonical URL to prevent duplicate content.
|
||||
drupal_add_html_head_link(array('rel' => 'canonical', 'href' => url($uri['path'], $uri['options'])), TRUE);
|
||||
// Set the non-aliased path as a default shortlink.
|
||||
drupal_add_html_head_link(array('rel' => 'shortlink', 'href' => url($uri['path'], array_merge($uri['options'], array('alias' => TRUE)))), TRUE);
|
||||
|
||||
// Trigger the main
|
||||
$build = taxonomy_term_show($term);
|
||||
|
||||
// Load my task plugin
|
||||
$task = page_manager_get_task('term_view');
|
||||
|
||||
// Load the term into a context.
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
$contexts = ctools_context_handler_get_task_contexts($task, '', array($term, $depth));
|
||||
|
||||
if (empty($contexts)) {
|
||||
return drupal_not_found();
|
||||
}
|
||||
|
||||
// Build the full output using the configured CTools plugin.
|
||||
$output = ctools_context_handler_render($task, '', $contexts, array($term->tid));
|
||||
if ($output !== FALSE) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Try loading an override plugin.
|
||||
foreach (module_implements('page_manager_override') as $module) {
|
||||
$call = $module . '_page_manager_override';
|
||||
if (($rc = $call('term_view')) && function_exists($rc)) {
|
||||
return $rc($node);
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, fall back to replicating the output normally generated by
|
||||
// taxonomy_term_page().
|
||||
|
||||
// Build breadcrumb based on the hierarchy of the term.
|
||||
$current = (object) array(
|
||||
'tid' => $term->tid,
|
||||
);
|
||||
// @todo This overrides any other possible breadcrumb and is a pure hard-coded
|
||||
// presumption. Make this behavior configurable per vocabulary or term.
|
||||
$breadcrumb = array();
|
||||
while ($parents = taxonomy_get_parents($current->tid)) {
|
||||
$current = array_shift($parents);
|
||||
$breadcrumb[] = l($current->name, 'taxonomy/term/' . $current->tid);
|
||||
}
|
||||
$breadcrumb[] = l(t('Home'), NULL);
|
||||
$breadcrumb = array_reverse($breadcrumb);
|
||||
drupal_set_breadcrumb($breadcrumb);
|
||||
drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->name);
|
||||
|
||||
if ($nids = taxonomy_select_nodes($term->tid, TRUE, variable_get('default_nodes_main', 10))) {
|
||||
$nodes = node_load_multiple($nids);
|
||||
$build += node_view_multiple($nodes);
|
||||
$build['pager'] = array(
|
||||
'#theme' => 'pager',
|
||||
'#weight' => 5,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$build['no_content'] = array(
|
||||
'#prefix' => '<p>',
|
||||
'#markup' => t('There is currently no content classified with this term.'),
|
||||
'#suffix' => '</p>',
|
||||
);
|
||||
}
|
||||
return $build;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get arguments provided by this task handler.
|
||||
*
|
||||
* Since this is the term view and there is no UI on the arguments, we
|
||||
* create dummy arguments that contain the needed data.
|
||||
*/
|
||||
function page_manager_term_view_get_arguments($task, $subtask_id) {
|
||||
return array(
|
||||
array(
|
||||
'keyword' => 'term',
|
||||
'identifier' => page_manager_term_view_get_type() == 'multiple' ? t('Term(s) being viewed') : t('Term being viewed'),
|
||||
'id' => 1,
|
||||
'name' => page_manager_term_view_get_type() == 'multiple' ? 'terms' : 'term',
|
||||
'settings' => array('input_form' => 'tid', 'breadcrumb' => variable_get('page_manager_taxonomy_breadcrumb', TRUE)),
|
||||
'default' => '404',
|
||||
),
|
||||
array(
|
||||
'keyword' => 'depth',
|
||||
'identifier' => t('Depth'),
|
||||
'id' => 1,
|
||||
'name' => 'string',
|
||||
'settings' => array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get context placeholders provided by this handler.
|
||||
*/
|
||||
function page_manager_term_view_get_contexts($task, $subtask_id) {
|
||||
return ctools_context_get_placeholders_from_argument(page_manager_term_view_get_arguments($task, $subtask_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings page for this item.
|
||||
*/
|
||||
function page_manager_term_view_settings($form, &$form_state) {
|
||||
// This passes thru because the setting can also appear on the main Panels
|
||||
// settings form. If $settings is an array it will just pick up the default.
|
||||
$settings = isset($form_state->update_values) ? $form_state->update_values : array();
|
||||
return page_manager_term_view_admin_settings($form, $settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy form values into the page cache.
|
||||
*/
|
||||
function page_manager_term_view_settings_submit(&$form, &$form_state) {
|
||||
$form_state['page']->update_values = $form_state['values'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Save when the page cache is saved.
|
||||
*/
|
||||
function page_manager_term_view_save($subtask, $cache) {
|
||||
if (isset($cache->update_values)) {
|
||||
variable_set('page_manager_term_view_type', $cache->update_values['page_manager_term_view_type']);
|
||||
variable_set('page_manager_taxonomy_breadcrumb', $cache->update_values['page_manager_taxonomy_breadcrumb']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a setting to the Panels administrative form.
|
||||
*/
|
||||
function page_manager_term_view_admin_settings($form, $settings = array()) {
|
||||
if (empty($settings)) {
|
||||
$settings = array(
|
||||
'page_manager_term_view_type' => page_manager_term_view_get_type(),
|
||||
'page_manager_taxonomy_breadcrumb' => variable_get('page_manager_taxonomy_breadcrumb', TRUE),
|
||||
);
|
||||
}
|
||||
|
||||
$form['page_manager_term_view_type'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Allow multiple terms on taxonomy/term/%term'),
|
||||
'#options' => array('single' => t('Single term'), 'multiple' => t('Multiple terms')),
|
||||
'#description' => t('By default, Drupal allows multiple terms as an argument by separating them with commas or plus signs. If you set this to single, that feature will be disabled.') . ' ' . t('This feature does not currently work and is disabled.'),
|
||||
'#default_value' => $settings['page_manager_term_view_type'],
|
||||
// @todo -- fix this
|
||||
'#disabled' => TRUE,
|
||||
);
|
||||
$form['page_manager_taxonomy_breadcrumb'] = array(
|
||||
'#title' => t('Inject hierarchy of first term into breadcrumb trail'),
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => $settings['page_manager_taxonomy_breadcrumb'],
|
||||
'#description' => t('If checked, taxonomy term parents will appear in the breadcrumb trail.'),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to enable/disable the page from the UI.
|
||||
*/
|
||||
function page_manager_term_view_enable($cache, $status) {
|
||||
variable_set('page_manager_term_view_disabled', $status);
|
||||
|
||||
// Set a global flag so that the menu routine knows it needs
|
||||
// to set a message if enabling cannot be done.
|
||||
if (!$status) {
|
||||
$GLOBALS['page_manager_enabling_term_view'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
function page_manager_term_view_get_type() {
|
||||
// $view_type = variable_get('page_manager_term_view_type', 'multiple');
|
||||
// Revert to just allowing single.
|
||||
$view_type = 'single';
|
||||
|
||||
return $view_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a nice administrative summary of the page so an admin can see at a
|
||||
* glance what this page does and how it is configured.
|
||||
*/
|
||||
function page_manager_term_view_admin_summary($task, $subtask) {
|
||||
$task_name = page_manager_make_task_name($task['name'], $subtask['name']);
|
||||
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-label'), 'data' => t('Path')),
|
||||
array('class' => array('page-summary-data'), 'data' => 'taxonomy/term/%term'),
|
||||
array('class' => array('page-summary-operation'), 'data' => ''),
|
||||
);
|
||||
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-label'), 'data' => t('Access')),
|
||||
array('class' => array('page-summary-data'), 'data' => t('This page is publicly accessible.')),
|
||||
array('class' => array('page-summary-operation'), 'data' => ''),
|
||||
);
|
||||
|
||||
$menu = t('No menu entry');
|
||||
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-label'), 'data' => t('Menu')),
|
||||
array('class' => array('page-summary-data'), 'data' => $menu),
|
||||
array('class' => array('page-summary-operation'), 'data' => ''),
|
||||
);
|
||||
|
||||
if (page_manager_term_view_get_type() == 'multiple') {
|
||||
$message = t('Multiple terms may be used, separated by , or +.');
|
||||
}
|
||||
else {
|
||||
$message = t('Only a single term may be used.');
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-label'), 'data' => t('%term')),
|
||||
array('class' => array('page-summary-data'), 'data' => $message),
|
||||
array('class' => array('page-summary-operation'), 'data' => ''),
|
||||
);
|
||||
|
||||
if (variable_get('page_manager_taxonomy_breadcrumb', TRUE)) {
|
||||
$message = t('Breadcrumb trail will contain taxonomy term hierarchy');
|
||||
}
|
||||
else {
|
||||
$message = t('Breadcrumb trail will not contain taxonomy term hiearchy.');
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
array('class' => array('page-summary-label'), 'data' => t('Breadcrumb')),
|
||||
array('class' => array('page-summary-data'), 'data' => $message),
|
||||
array('class' => array('page-summary-operation'), 'data' => ''),
|
||||
);
|
||||
|
||||
$output = theme('table', array(), $rows, array('id' => 'page-manager-page-summary'));
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine if a page is accessible.
|
||||
*
|
||||
* @param $task
|
||||
* The task plugin.
|
||||
* @param $subtask_id
|
||||
* The subtask id
|
||||
* @param $contexts
|
||||
* The contexts loaded for the task.
|
||||
* @return
|
||||
* TRUE if the current user can access the page.
|
||||
*/
|
||||
function page_manager_term_view_access_check($task, $subtask_id, $contexts) {
|
||||
return user_access('access content');
|
||||
}
|
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Overrides the user profile display at user/%user.
|
||||
*
|
||||
* Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
|
||||
* more information.
|
||||
*/
|
||||
function page_manager_user_edit_page_manager_tasks() {
|
||||
return array(
|
||||
// This is a 'page' task and will fall under the page admin UI
|
||||
'task type' => 'page',
|
||||
'title' => t('User Edit Template'),
|
||||
'admin title' => t('User edit template'),
|
||||
'admin description' => t('When enabled, this overrides the default Drupal behavior for displaying user edit form at <em>user/%user/edit</em>.'),
|
||||
'admin path' => 'user/%user/edit',
|
||||
|
||||
// Callback to add items to the page managertask administration form:
|
||||
'task admin' => 'page_manager_user_edit_task_admin',
|
||||
|
||||
'hook menu' => 'page_manager_user_edit_menu',
|
||||
'hook menu alter' => 'page_manager_user_edit_menu_alter',
|
||||
|
||||
// This is task uses 'context' handlers and must implement these to give the
|
||||
// handler data it needs.
|
||||
'handler type' => 'context', // handler type -- misnamed
|
||||
'get arguments' => 'page_manager_user_edit_get_arguments',
|
||||
'get context placeholders' => 'page_manager_user_edit_get_contexts',
|
||||
|
||||
// Allow this to be enabled or disabled:
|
||||
'disabled' => variable_get('page_manager_user_edit_disabled', TRUE),
|
||||
'enable callback' => 'page_manager_user_edit_enable',
|
||||
'access callback' => 'page_manager_user_edit_access_check',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback defined by page_manager_user_view_page_manager_tasks().
|
||||
*
|
||||
* Alter the user view input so that user view comes to us rather than the
|
||||
* normal user view process.
|
||||
*/
|
||||
function page_manager_user_edit_menu_alter(&$items, $task) {
|
||||
if (variable_get('page_manager_user_edit_disabled', TRUE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Override the user view handler for our purpose.
|
||||
if ($items['user/%user/edit']['page callback'] == 'drupal_get_form' || variable_get('page_manager_override_anyway', FALSE)) {
|
||||
$items['user/%user/edit']['page callback'] = 'page_manager_user_edit_page';
|
||||
$items['user/%user/edit']['page arguments'] = array(1);
|
||||
$items['user/%user/edit']['file path'] = $task['path'];
|
||||
$items['user/%user/edit']['file'] = $task['file'];
|
||||
if (($categories = _user_categories()) && (count($categories) > 1)) {
|
||||
foreach ($categories as $key => $category) {
|
||||
// 'account' is already handled by the MENU_DEFAULT_LOCAL_TASK.
|
||||
if ($category['name'] != 'account') {
|
||||
$items['user/%user_category/edit/' . $category['name']]['page callback'] = 'page_manager_user_edit_page';
|
||||
$items['user/%user_category/edit/' . $category['name']]['page arguments'] = array(1, 3);
|
||||
$items['user/%user_category/edit/' . $category['name']]['file path'] = $task['path'];
|
||||
$items['user/%user_category/edit/' . $category['name']]['file'] = $task['file'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// automatically disable this task if it cannot be enabled.
|
||||
variable_set('page_manager_user_edit_disabled', TRUE);
|
||||
if (!empty($GLOBALS['page_manager_enabling_user_edit'])) {
|
||||
drupal_set_message(t('Page manager module is unable to enable user/%user/edit because some other module already has overridden with %callback.', array('%callback' => $items['user/%user']['page callback'])), 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for our overridden user view.
|
||||
*
|
||||
* This function asks its assigned handlers who, if anyone, would like
|
||||
* to run with it. If no one does, it passes through to Drupal core's
|
||||
* user edit, which is drupal_get_form('user_profile_form',$account).
|
||||
*/
|
||||
function page_manager_user_edit_page($account, $category = 'account') {
|
||||
// Store the category on the user for later usage.
|
||||
$account->user_category = $category;
|
||||
|
||||
// Load my task plugin:
|
||||
$task = page_manager_get_task('user_edit');
|
||||
|
||||
// Load the account into a context.
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
$contexts = ctools_context_handler_get_task_contexts($task, '', array($account));
|
||||
// Build content. @todo -- this may not be right.
|
||||
user_build_content($account);
|
||||
|
||||
$output = ctools_context_handler_render($task, '', $contexts, array($account->uid));
|
||||
if (is_array($output)) {
|
||||
$output = drupal_render($output);
|
||||
}
|
||||
if ($output != FALSE) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
$function = 'drupal_get_form';
|
||||
foreach (module_implements('page_manager_override') as $module) {
|
||||
$call = $module . '_page_manager_override';
|
||||
if (($rc = $call('user_edit')) && function_exists($rc)) {
|
||||
$function = $rc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, fall back.
|
||||
if ($function == 'drupal_get_form') {
|
||||
|
||||
//In order to ajax fields to work we need to run form_load_include.
|
||||
//Hence we eschew drupal_get_form and manually build the info and
|
||||
//call drupal_build_form.
|
||||
$form_state = array();
|
||||
$form_id = 'user_profile_form';
|
||||
$args = array($account);
|
||||
$form_state['build_info']['args'] = $args;
|
||||
form_load_include($form_state, 'inc', 'user', 'user.pages');
|
||||
$output = drupal_build_form($form_id, $form_state);
|
||||
return $output;
|
||||
}
|
||||
//fire off "view" op so that triggers still work
|
||||
// @todo -- this doesn't work anymore, and the alternatives seem bad.
|
||||
// will have to figure out how to fix this.
|
||||
// user_module_invoke('view', $array = array(), $account);
|
||||
return $function($account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get arguments provided by this task handler.
|
||||
*
|
||||
* Since this is the node view and there is no UI on the arguments, we
|
||||
* create dummy arguments that contain the needed data.
|
||||
*/
|
||||
function page_manager_user_edit_get_arguments($task, $subtask_id) {
|
||||
return array(
|
||||
array(
|
||||
'keyword' => 'user',
|
||||
'identifier' => t('User being edited'),
|
||||
'id' => 1,
|
||||
'name' => 'user_edit',
|
||||
'settings' => array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get context placeholders provided by this handler.
|
||||
*/
|
||||
function page_manager_user_edit_get_contexts($task, $subtask_id) {
|
||||
return ctools_context_get_placeholders_from_argument(page_manager_user_edit_get_arguments($task, $subtask_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to enable/disable the page from the UI.
|
||||
*/
|
||||
function page_manager_user_edit_enable($cache, $status) {
|
||||
variable_set('page_manager_user_edit_disabled', $status);
|
||||
// Set a global flag so that the menu routine knows it needs
|
||||
// to set a message if enabling cannot be done.
|
||||
if (!$status) {
|
||||
$GLOBALS['page_manager_enabling_user_edit'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine if a page is accessible.
|
||||
*
|
||||
* @param $task
|
||||
* The task plugin.
|
||||
* @param $subtask_id
|
||||
* The subtask id
|
||||
* @param $contexts
|
||||
* The contexts loaded for the task.
|
||||
* @return
|
||||
* TRUE if the current user can access the page.
|
||||
*/
|
||||
function page_manager_user_edit_access_check($task, $subtask_id, $contexts) {
|
||||
$context = reset($contexts);
|
||||
return user_edit_access($context->data);
|
||||
}
|
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Overrides the user profile display at user/%user.
|
||||
*
|
||||
* Specialized implementation of hook_page_manager_task_tasks(). See api-task.html for
|
||||
* more information.
|
||||
*/
|
||||
function page_manager_user_view_page_manager_tasks() {
|
||||
return array(
|
||||
// This is a 'page' task and will fall under the page admin UI
|
||||
'task type' => 'page',
|
||||
'title' => t('User profile template'),
|
||||
'admin title' => t('User profile template'),
|
||||
'admin description' => t('When enabled, this overrides the default Drupal behavior for displaying user profiles at <em>user/%user</em>. If you add variants, you may use selection criteria such as roles or user access to provide different views of user profiles. If no variant is selected, the default Drupal user view will be used. Please note that if you are using pathauto, aliases may make a node to be somewhere else, but as far as Drupal is concerned, they are still at user/%user.'),
|
||||
'admin path' => 'user/%user',
|
||||
|
||||
// Callback to add items to the page managertask administration form:
|
||||
'task admin' => 'page_manager_user_view_task_admin',
|
||||
|
||||
'hook menu' => 'page_manager_user_view_menu',
|
||||
'hook menu alter' => 'page_manager_user_view_menu_alter',
|
||||
|
||||
// This is task uses 'context' handlers and must implement these to give the
|
||||
// handler data it needs.
|
||||
'handler type' => 'context', // handler type -- misnamed
|
||||
'get arguments' => 'page_manager_user_view_get_arguments',
|
||||
'get context placeholders' => 'page_manager_user_view_get_contexts',
|
||||
|
||||
// Allow this to be enabled or disabled:
|
||||
'disabled' => variable_get('page_manager_user_view_disabled', TRUE),
|
||||
'enable callback' => 'page_manager_user_view_enable',
|
||||
'access callback' => 'page_manager_user_view_access_check',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback defined by page_manager_user_view_page_manager_tasks().
|
||||
*
|
||||
* Alter the user view input so that user view comes to us rather than the
|
||||
* normal user view process.
|
||||
*/
|
||||
function page_manager_user_view_menu_alter(&$items, $task) {
|
||||
if (variable_get('page_manager_user_view_disabled', TRUE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Override the user view handler for our purpose.
|
||||
if ($items['user/%user']['page callback'] == 'user_view_page' || variable_get('page_manager_override_anyway', FALSE)) {
|
||||
$items['user/%user']['page callback'] = 'page_manager_user_view_page';
|
||||
$items['user/%user']['file path'] = $task['path'];
|
||||
$items['user/%user']['file'] = $task['file'];
|
||||
}
|
||||
else {
|
||||
// automatically disable this task if it cannot be enabled.
|
||||
variable_set('page_manager_user_view_disabled', TRUE);
|
||||
if (!empty($GLOBALS['page_manager_enabling_user_view'])) {
|
||||
drupal_set_message(t('Page manager module is unable to enable user/%user because some other module already has overridden with %callback.', array('%callback' => $items['user/%user']['page callback'])), 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point for our overridden user view.
|
||||
*
|
||||
* This function asks its assigned handlers who, if anyone, would like
|
||||
* to run with it. If no one does, it passes through to Drupal core's
|
||||
* user view, which is user_page_view().
|
||||
*/
|
||||
function page_manager_user_view_page($account) {
|
||||
// Load my task plugin:
|
||||
$task = page_manager_get_task('user_view');
|
||||
|
||||
// Load the account into a context.
|
||||
ctools_include('context');
|
||||
ctools_include('context-task-handler');
|
||||
$contexts = ctools_context_handler_get_task_contexts($task, '', array($account));
|
||||
|
||||
// Build content. @todo -- this may not be right.
|
||||
user_build_content($account);
|
||||
|
||||
$output = ctools_context_handler_render($task, '', $contexts, array($account->uid));
|
||||
if ($output != FALSE) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
$function = 'user_view';
|
||||
foreach (module_implements('page_manager_override') as $module) {
|
||||
$call = $module . '_page_manager_override';
|
||||
if (($rc = $call('user_view')) && function_exists($rc)) {
|
||||
$function = $rc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, fall back.
|
||||
if ($function == 'user_view') {
|
||||
module_load_include('inc', 'user', 'user.pages');
|
||||
}
|
||||
//fire off "view" op so that triggers still work
|
||||
// @todo -- this doesn't work anymore, and the alternatives seem bad.
|
||||
// will have to figure out how to fix this.
|
||||
// user_module_invoke('view', $array = array(), $account);
|
||||
return $function($account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get arguments provided by this task handler.
|
||||
*
|
||||
* Since this is the node view and there is no UI on the arguments, we
|
||||
* create dummy arguments that contain the needed data.
|
||||
*/
|
||||
function page_manager_user_view_get_arguments($task, $subtask_id) {
|
||||
return array(
|
||||
array(
|
||||
'keyword' => 'user',
|
||||
'identifier' => t('User being viewed'),
|
||||
'id' => 1,
|
||||
'name' => 'entity_id:user',
|
||||
'settings' => array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to get context placeholders provided by this handler.
|
||||
*/
|
||||
function page_manager_user_view_get_contexts($task, $subtask_id) {
|
||||
return ctools_context_get_placeholders_from_argument(page_manager_user_view_get_arguments($task, $subtask_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to enable/disable the page from the UI.
|
||||
*/
|
||||
function page_manager_user_view_enable($cache, $status) {
|
||||
variable_set('page_manager_user_view_disabled', $status);
|
||||
|
||||
// Set a global flag so that the menu routine knows it needs
|
||||
// to set a message if enabling cannot be done.
|
||||
if (!$status) {
|
||||
$GLOBALS['page_manager_enabling_user_view'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to determine if a page is accessible.
|
||||
*
|
||||
* @param $task
|
||||
* The task plugin.
|
||||
* @param $subtask_id
|
||||
* The subtask id
|
||||
* @param $contexts
|
||||
* The contexts loaded for the task.
|
||||
* @return
|
||||
* TRUE if the current user can access the page.
|
||||
*/
|
||||
function page_manager_user_view_access_check($task, $subtask_id, $contexts) {
|
||||
$context = reset($contexts);
|
||||
return user_view_access($context->data);
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Template for the page manager page editor.
|
||||
*
|
||||
* Variables available:
|
||||
* -
|
||||
*
|
||||
* For javascript purposes the id must not change.
|
||||
*/
|
||||
?>
|
||||
<div id="page-manager-edit">
|
||||
<?php print $locked; ?>
|
||||
<div class="page-manager-wrapper">
|
||||
<?php if (isset($operations['primary'])): ?>
|
||||
<div class="primary-actions clearfix actions">
|
||||
<?php print $operations['primary']; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="page-manager-tabs clearfix">
|
||||
<div class="page-manager-edit-operations">
|
||||
<div class="inside">
|
||||
<?php print $operations['nav']; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="page-manager-ajax-pad">
|
||||
<div class="inside">
|
||||
<div class="content-header">
|
||||
<div class="content-title">
|
||||
<?php print $changed; ?>
|
||||
<?php print $content['title']; ?>
|
||||
</div>
|
||||
<?php if (isset($operations['secondary'])): ?>
|
||||
<div class="secondary-actions clearfix actions">
|
||||
<?php print $operations['secondary']; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="content-content">
|
||||
<?php if (!empty($content['description'])): ?>
|
||||
<div class="description">
|
||||
<?php print $content['description']; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php print $content['content']; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php print $save; ?>
|
||||
</div>
|
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Preprocess functions for page manager editing templates.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Preprocess the page manager edit page.
|
||||
*/
|
||||
function template_preprocess_page_manager_edit_page(&$vars) {
|
||||
ctools_include('ajax');
|
||||
ctools_include('modal');
|
||||
ctools_modal_add_js();
|
||||
ctools_add_js('dependent');
|
||||
|
||||
ctools_add_css('page-manager', 'page_manager');
|
||||
ctools_add_css('wizard');
|
||||
|
||||
$task = $vars['page']->task;
|
||||
|
||||
$page = &$vars['page'];
|
||||
|
||||
$vars['locked'] = '';
|
||||
$vars['changed'] = '';
|
||||
if (!empty($page->locked)) {
|
||||
$vars['locked'] = theme('page_manager_lock', array('page' => $page));
|
||||
$vars['changed'] = theme('page_manager_changed', array('text' => t('Locked'), 'description' => t('This page is being edited by another user and you cannot make changes to it.')));
|
||||
}
|
||||
else if (!empty($page->new)) {
|
||||
$vars['changed'] = theme('page_manager_changed', array('text' => t('New'), 'description' => t('This page is newly created and has not yet been saved to the database. It will not be available until you save it.')));
|
||||
}
|
||||
else if (!empty($page->changed)) {
|
||||
$vars['changed'] = theme('page_manager_changed', array('text' => t('Changed'), 'description' => t('This page has been modified, but these modifications are not yet live. While modifying this page, it is locked from modification by other users.')));
|
||||
}
|
||||
|
||||
$form_state = array(
|
||||
'page' => &$vars['page'],
|
||||
);
|
||||
|
||||
$active = $vars['content']['active'];
|
||||
if ($active[0] == 'handlers' && isset($vars['operations'][$active[1]])) {
|
||||
$vars['operations']['secondary'] = $vars['operations'][$active[1]];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn the rearrange form into a table with tablesorting on.
|
||||
*/
|
||||
function theme_page_manager_handler_rearrange($vars) {
|
||||
$form = &$vars['form'];
|
||||
// Assemble the data for a table from everything in $form['handlers']
|
||||
foreach (element_children($form['handlers']) as $id) {
|
||||
// provide a reference shortcut.
|
||||
$element = &$form['handlers'][$id];
|
||||
if (isset($element['title'])) {
|
||||
$row = array();
|
||||
|
||||
$row[] = array(
|
||||
'data' => render($element['title']),
|
||||
'class' => array('page-manager-handler'),
|
||||
);
|
||||
|
||||
$element['weight']['#attributes']['class'][] = 'weight';
|
||||
$row[] = render($element['weight']);
|
||||
|
||||
$rows[] = array('data' => $row, 'class' => array('draggable'), 'id' => 'page-manager-row-' . $id);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($rows)) {
|
||||
$rows[] = array(array('data' => t('No task handlers are defined for this task.'), 'colspan' => '5'));
|
||||
}
|
||||
|
||||
$header = array(
|
||||
array('data' => t('Variant'), 'class' => array('page-manager-handler')),
|
||||
t('Weight'),
|
||||
);
|
||||
|
||||
drupal_add_tabledrag('page-manager-arrange-handlers', 'order', 'sibling', 'weight');
|
||||
|
||||
$output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'page-manager-arrange-handlers')));
|
||||
$output .= drupal_render_children($form);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the "this task is locked from editing" box.
|
||||
*/
|
||||
function theme_page_manager_lock($vars) {
|
||||
$page = $vars['page'];
|
||||
|
||||
$account = user_load($page->locked->uid);
|
||||
$name = theme('username', array('account' => $account));
|
||||
$lock_age = format_interval(REQUEST_TIME - $page->locked->updated);
|
||||
$break = url(page_manager_edit_url($page->task_name, array('actions', 'break-lock')));
|
||||
|
||||
ctools_add_css('ctools');
|
||||
$output = '<div class="ctools-locked">';
|
||||
$output .= t('This page is being edited by user !user, and is therefore locked from editing by others. This lock is !age old. Click here to <a href="!break">break this lock</a>.', array('!user' => $name, '!age' => $lock_age, '!break' => $break));
|
||||
$output .= '</div>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the "you have unsaved changes and this task is locked." message.
|
||||
*/
|
||||
function theme_page_manager_changed($vars) {
|
||||
$text = $vars['text'];
|
||||
$description = $vars['description'];
|
||||
|
||||
ctools_add_css('ctools');
|
||||
$output = '<div class="page-manager-changed" title="' . $description . '">';
|
||||
$output .= $text;
|
||||
$output .= '</div>';
|
||||
|
||||
return $output;
|
||||
}
|
Reference in New Issue
Block a user