summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Miles2009-08-17 21:35:20 (GMT)
committer Earl Miles2009-08-17 21:35:20 (GMT)
commit94976edc0f9ad34ac8f08ad3c2324cd465b0ab80 (patch)
treed933ea08e25c9d4fe12852575cd7e4ed195c5e06
parent4c430abec33dcc676244e87101e94c91987ea94e (diff)
#545540 by Roger López: Add 5 page elements as available panes for using Panels as your primary page layout: breadcrumb, page title, messages, tabs and help box.
-rw-r--r--API.txt3
-rw-r--r--CHANGELOG.txt1
-rw-r--r--ctools.module57
3 files changed, 60 insertions, 1 deletions
diff --git a/API.txt b/API.txt
index b7fca15..767dd97 100644
--- a/API.txt
+++ b/API.txt
@@ -4,7 +4,8 @@ This file contains a log of changes to the API.
API version 1.1.1:
Introduce ctools_plugin_get_class() and ctools_plugin_load_class()
- Introdue ctools_ajax_command_attr().
+ Introduce ctools_ajax_command_attr().
+ Introduce ctools_set_page_token().
API version 1.1.0:
delegator module destroyed, replaced by page manager. All 'task' and 'task_handler' plugins
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index d08e1fe..e7a824c 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -17,6 +17,7 @@ Make sure that tasks that will not override existing overrides refuse to enable
#478542 by nickl: Add "attr" command to ajax framework.
#495240 by mikl: Blob handling for pgsql.
#531936: Cache handling on contexts was spotty and could cause random errors.
+#545540 by Roger López: Add 5 page elements as available panes for using Panels as your primary page layout: breadcrumb, page title, messages, tabs and help box.
ctools 6.x-1.0-rc1
==================
diff --git a/ctools.module b/ctools.module
index 9bc8256..5a03d30 100644
--- a/ctools.module
+++ b/ctools.module
@@ -360,3 +360,60 @@ function ctools_js_load($js) {
}
return 0;
}
+
+/**
+ * A theme preprocess function to allow content type plugins to use page
+ * template variables which are not yet available when the content type is
+ * rendered.
+ */
+function ctools_preprocess_page(&$variables) {
+ $tokens = ctools_set_page_token();
+ if (!empty($tokens)) {
+ foreach ($tokens as $token => $key) {
+ list($type, $argument) = $key;
+ switch ($type) {
+ case 'variable':
+ $tokens[$token] = isset($variables[$argument]) ? $variables[$argument] : '';
+ break;
+ case 'callback':
+ if (is_string($argument) && function_exists($argument)) {
+ $tokens[$token] = $argument();
+ }
+ if (is_array($argument) && function_exists($argument[0])) {
+ $tokens[$token] = call_user_func_array($argument);
+ }
+ break;
+ }
+ $variables['content'] = strtr($variables['content'], $tokens);
+ }
+ }
+}
+
+/**
+ * Set a token/value pair to be replaced later in the request, specifically in
+ * ctools_preprocess_page().
+ *
+ * @param $token
+ * The token to be replaced later, during page rendering. This should
+ * ideally be a string inside of an HTML comment, so that if there is
+ * no replacement, the token will not render on the page.
+ * @param $type
+ * The type of the token. Can be either 'variable', which will pull data
+ * directly from the page variables
+ * @param $argument
+ * If $type == 'variable' then argument should be the key to fetch from
+ * the $variables. If $type == 'callback' then it should either be the
+ * callback, or an array that will be sent to call_user_func_array().
+ *
+ * @return
+ * A array of token/variable names to be replaced.
+ */
+function ctools_set_page_token($token = NULL, $type = NULL, $argument = NULL) {
+ static $tokens = array();
+
+ if (isset($token)) {
+ $tokens[$token] = array($type, $argument);
+ }
+
+ return $tokens;
+} \ No newline at end of file