| 1 |
<?php |
<?php |
| 2 |
|
|
| 3 |
// $Id |
// $Id$ |
| 4 |
|
|
| 5 |
/** |
/** |
| 6 |
* Form API callback for Tokens tab |
* Form API callback for Tokens tab |
| 210 |
foreach ($skeleton_tokens as $token => $value) { |
foreach ($skeleton_tokens as $token => $value) { |
| 211 |
$tokens[$token] = $value; |
$tokens[$token] = $value; |
| 212 |
} |
} |
|
return $tokens; |
|
| 213 |
} |
} |
| 214 |
|
return $tokens; |
| 215 |
} |
} |
| 216 |
|
|
| 217 |
/** |
/** |
| 289 |
} |
} |
| 290 |
|
|
| 291 |
/** |
/** |
| 292 |
|
* Replace tokens within the title, body, and an CCK text fields on a node. |
| 293 |
|
* |
| 294 |
|
* @param $node |
| 295 |
|
* The node object to act upon. |
| 296 |
|
* |
| 297 |
|
* @param $type |
| 298 |
|
* The token type to replace, corresponding to the types used with |
| 299 |
|
* token_replace(). |
| 300 |
|
* |
| 301 |
|
* @param $tokens |
| 302 |
|
* The tokens to pass to token_replace(). |
| 303 |
|
* |
| 304 |
|
* @param $fix_bookpathalias [optional] |
| 305 |
|
* If the node contains [bookpathalias] tokens, replace them manually so that |
| 306 |
|
* it can be used when the node hasn't been saved yet. |
| 307 |
|
* |
| 308 |
|
* @return |
| 309 |
|
* The node object with the tokenized title, body, and CCK text fields. |
| 310 |
|
*/ |
| 311 |
|
function _skeleton_token_replace_values($node, $type, $tokens, $fix_bookpathalias = FALSE) { |
| 312 |
|
// For subpages, we can simply simulate the [bookpathalias] token here. |
| 313 |
|
// Otherwise, it will be replaced with '' during token_replace() as the |
| 314 |
|
// node isn't saved yet. |
| 315 |
|
if ($fix_bookpathalias && module_exists('pathauto')) { |
| 316 |
|
$book_root = node_load($node->book['bid']); |
| 317 |
|
$node->title = str_replace('[bookpathalias]', drupal_get_path_alias($book_root->path), $node->title); |
| 318 |
|
$node->body = str_replace('[bookpathalias]', drupal_get_path_alias($book_root->path), $node->body); |
| 319 |
|
} |
| 320 |
|
$node->title = token_replace($node->title, $type, $tokens); |
| 321 |
|
$node->body = token_replace($node->body, $type, $tokens); |
| 322 |
|
// Also do any CCK text fields. |
| 323 |
|
$content_type = content_types($node->type); |
| 324 |
|
$fields = $content_type['fields']; |
| 325 |
|
foreach ($fields as $field) { |
| 326 |
|
if ($field['type'] == 'text' && is_array($node->{$field['field_name']})) { |
| 327 |
|
foreach (array_keys($node->{$field['field_name']}) as $delta) { |
| 328 |
|
$node->{$field['field_name']}[$delta]['value'] = token_replace($node->{$field['field_name']}[$delta]['value'], $type, $tokens); |
| 329 |
|
} |
| 330 |
|
} |
| 331 |
|
} |
| 332 |
|
return $node; |
| 333 |
|
} |
| 334 |
|
|
| 335 |
|
/** |
| 336 |
* theme_skeleton_token_help() |
* theme_skeleton_token_help() |
| 337 |
* |
* |
| 338 |
* @param $tokens |
* @param $tokens |