| 1 |
<?php |
<?php |
| 2 |
// $Id: contemplate.module,v 1.8.4.60 2009/05/07 22:15:44 jrglasgow Exp $ |
// $Id: contemplate.module,v 1.8.4.61 2009/05/11 21:20:54 jrglasgow Exp $ |
| 3 |
// by Jeff Robbins - Lullabot - www.lullabot.com |
// by Jeff Robbins - Lullabot - www.lullabot.com |
| 4 |
|
|
| 5 |
define('CONTEMPLATE_TEASER_ENABLED', 0x0001); |
define('CONTEMPLATE_TEASER_ENABLED', 0x0001); |
| 72 |
'access arguments' => array('administer templates'), |
'access arguments' => array('administer templates'), |
| 73 |
); |
); |
| 74 |
$node_types = node_get_types(); |
$node_types = node_get_types(); |
| 75 |
foreach ($node_types as $type) { |
foreach (node_get_types('types', NULL, TRUE) as $type) { |
| 76 |
$items['admin/content/node-type/'. $type->type .'/template'] = array( |
$type_url_str = str_replace('_', '-', $type->type); |
| 77 |
|
$items['admin/content/node-type/'. $type_url_str .'/template'] = array( |
| 78 |
'title' => 'Template', |
'title' => 'Template', |
| 79 |
'page callback' => 'contemplate_edit_type', |
'page callback' => 'contemplate_edit_type', |
| 80 |
'page arguments' => array(3), |
'page arguments' => array($type), |
|
'access callback' => 'user_access', |
|
| 81 |
'access arguments' => array('administer templates'), |
'access arguments' => array('administer templates'), |
| 82 |
'type' => MENU_LOCAL_TASK, |
'type' => MENU_LOCAL_TASK, |
| 83 |
'weight' => 7, |
'weight' => 10, |
| 84 |
); |
); |
| 85 |
} |
} |
| 86 |
$items['admin/settings/contemplate'] = array( |
$items['admin/settings/contemplate'] = array( |
| 205 |
$disabled = t('Disabled'); |
$disabled = t('Disabled'); |
| 206 |
$file = t('Enabled: Disk'); |
$file = t('Enabled: Disk'); |
| 207 |
foreach ($types as $type) { |
foreach ($types as $type) { |
| 208 |
|
$type_url_str = str_replace('_', '-', $type->type); |
| 209 |
$rows[] = array( |
$rows[] = array( |
| 210 |
$type->name, |
$type->name, |
| 211 |
isset($templates[$type->type]['teaser-enabled']) ? ($templates[$type->type]['teaser-enabled'] ? ($templates[$type->type]['teaser-file'] ? $file : $enabled) : $disabled) : '', |
isset($templates[$type->type]['teaser-enabled']) ? ($templates[$type->type]['teaser-enabled'] ? ($templates[$type->type]['teaser-file'] ? $file : $enabled) : $disabled) : '', |
| 212 |
isset($templates[$type->type]['body-enabled']) ? ($templates[$type->type]['body-enabled'] ? ($templates[$type->type]['body-file'] ? $file : $enabled) : $disabled) : '', |
isset($templates[$type->type]['body-enabled']) ? ($templates[$type->type]['body-enabled'] ? ($templates[$type->type]['body-file'] ? $file : $enabled) : $disabled) : '', |
| 213 |
isset($templates[$type->type]['rss-enabled']) ? ($templates[$type->type]['rss-enabled'] ? ($templates[$type->type]['rss-file'] ? $file : $enabled) : $disabled) : '', |
isset($templates[$type->type]['rss-enabled']) ? ($templates[$type->type]['rss-enabled'] ? ($templates[$type->type]['rss-file'] ? $file : $enabled) : $disabled) : '', |
| 214 |
l(isset($templates[$type->type]) ? t('edit template') : t('create template'), 'admin/content/node-type/'. $type->type .'/template'), |
l(isset($templates[$type->type]) ? t('edit template') : t('create template'), 'admin/content/node-type/'. $type_url_str .'/template'), |
| 215 |
(isset($templates[$type->type]) ? l(t('delete template'), 'admin/content/node-type/'. $type->type .'/template/delete', array('query' => $destination)) : ''), |
(isset($templates[$type->type]) ? l(t('delete template'), 'admin/content/node-type/'. $type_url_str .'/template/delete', array('query' => $destination)) : ''), |
| 216 |
); |
); |
| 217 |
} |
} |
| 218 |
$header = array( |
$header = array( |
| 441 |
return $form; |
return $form; |
| 442 |
} |
} |
| 443 |
|
|
| 444 |
function contemplate_edit_type($type = NULL) { |
function contemplate_edit_type($type = array()) { |
| 445 |
$types = node_get_types(); |
if (empty($type)) { // if the argument isn't a valid node type, output admin page |
|
|
|
|
if (empty($types[$type])) { // if the argument isn't a valid node type, output admin page |
|
| 446 |
return contemplate_admin(); |
return contemplate_admin(); |
| 447 |
} |
} |
| 448 |
drupal_set_title(t('Template for %type', array('%type' => $types[$type]->name))); |
drupal_set_title(t('Template for %type', array('%type' => $type->name))); |
| 449 |
if (arg(0) == 'admin' && arg(1) == 'content' && arg(4) == 'template') { |
if (arg(0) == 'admin' && arg(1) == 'content' && arg(4) == 'template') { |
| 450 |
$breadcrumbs = drupal_get_breadcrumb(); |
$breadcrumbs = drupal_get_breadcrumb(); |
| 451 |
$type_crumb = array_pop($breadcrumbs); |
$type_crumb = array_pop($breadcrumbs); |
| 453 |
drupal_set_breadcrumb($breadcrumbs); |
drupal_set_breadcrumb($breadcrumbs); |
| 454 |
} |
} |
| 455 |
if (arg(5) == 'delete') { |
if (arg(5) == 'delete') { |
| 456 |
return drupal_get_form('contemplate_delete_type_form', $type); |
return drupal_get_form('contemplate_delete_type_form', $type->type); |
| 457 |
} |
} |
| 458 |
else { |
else { |
| 459 |
contemplate_refresh_files(); |
contemplate_refresh_files(); |
| 460 |
return drupal_get_form('contemplate_edit_type_form', $type); |
return drupal_get_form('contemplate_edit_type_form', $type->type); |
| 461 |
} |
} |
| 462 |
} |
} |
| 463 |
|
|