| 1 |
<?php
|
| 2 |
// $Id: rpg.theme.inc,v 1.11 2008/03/08 00:31:04 aaron Exp $
|
| 3 |
|
| 4 |
function theme_rpg_play($pc) {
|
| 5 |
$output = t('You are playing !pc.', array('!pc' => l(rpg_get('name', $pc), 'rpg/view/' . rpg_id($pc))));
|
| 6 |
return $output;
|
| 7 |
}
|
| 8 |
|
| 9 |
function theme_rpg_character_select_page($account, $pcs) {
|
| 10 |
$items = array();
|
| 11 |
if (count($pcs)) {
|
| 12 |
foreach ($pcs as $pc) {
|
| 13 |
$items[] = l(rpg_get('name', $pc), 'rpg/select/' . $pc);
|
| 14 |
}
|
| 15 |
}
|
| 16 |
$output .= theme('item_list', $items);
|
| 17 |
$output .= l(t('Create Character'), 'rpg/create/pc');
|
| 18 |
return $output;
|
| 19 |
}
|
| 20 |
|
| 21 |
function theme_rpg_create_pc_page($pc, $type, $form) {
|
| 22 |
drupal_set_title(t('Create @type Player Character', array('@type' => $type['name'])));
|
| 23 |
$output .= $type['longdesc'];
|
| 24 |
$output .= $form;
|
| 25 |
return $output;
|
| 26 |
}
|
| 27 |
|
| 28 |
/**
|
| 29 |
* display the form for object creation
|
| 30 |
* @param $object
|
| 31 |
* the newly created object with appropriate properties already populated for the type
|
| 32 |
* @param $type
|
| 33 |
* the type array for the object
|
| 34 |
* @param $form
|
| 35 |
* the form to display
|
| 36 |
*/
|
| 37 |
function theme_rpg_create_object_page($object, $type, $form) {
|
| 38 |
drupal_set_title(t('Create @type', array('@type' => $type['name'])));
|
| 39 |
$output .= $type['longdesc'];
|
| 40 |
$output .= $form;
|
| 41 |
return $output;
|
| 42 |
}
|
| 43 |
|
| 44 |
/**
|
| 45 |
* display the form for editing an rpg object
|
| 46 |
* @param $object
|
| 47 |
* the loaded object
|
| 48 |
* @param $form
|
| 49 |
* the form to display
|
| 50 |
*/
|
| 51 |
function theme_rpg_edit_object_page($object, $form) {
|
| 52 |
drupal_set_title(t('Edit @obj', array('@obj' => rpg_get('name', $object))));
|
| 53 |
$output .= $form;
|
| 54 |
return $output;
|
| 55 |
}
|
| 56 |
|
| 57 |
/**
|
| 58 |
* display the form for viewing an rpg object
|
| 59 |
* @param $object
|
| 60 |
* the loaded object
|
| 61 |
* TODO: hooks
|
| 62 |
* TODO: action links
|
| 63 |
*/
|
| 64 |
function theme_rpg_view_object_page($object) {
|
| 65 |
$name = rpg_get('name', $object);
|
| 66 |
$title = t('@name', array('@name' => $name));
|
| 67 |
drupal_set_title($title);
|
| 68 |
$output .= '<div class="rpg_view_object">';
|
| 69 |
$output .= '<div class="content">';
|
| 70 |
$output .= rpg_get('description', $object);
|
| 71 |
$output .= '</div><!--close content-->';
|
| 72 |
|
| 73 |
// $links = rpg_invoke($object, 'actions', $rpg['pc']);
|
| 74 |
// TODO: rpg_edit_access???
|
| 75 |
if (user_access('administer rpg')) {
|
| 76 |
$links[] = l(t('edit @name', array('@name' => $name)), 'rpg/edit/' . rpg_id($object));
|
| 77 |
}
|
| 78 |
if (!empty($links)) {
|
| 79 |
$output .= '<div class="links">';
|
| 80 |
$output .= theme('item_list', $links);
|
| 81 |
$output .= '</div>';
|
| 82 |
}
|
| 83 |
$output .= '</div>';
|
| 84 |
return $output;
|
| 85 |
}
|
| 86 |
|
| 87 |
function theme_rpg_admin_types($types) {
|
| 88 |
$output .= t('The following types are available for creating objects in the RPG. You may edit, delete, or add to the types from the following table:');
|
| 89 |
$header = array(t('Type'), t('Description'), t('Operations'));
|
| 90 |
$rows = array();
|
| 91 |
foreach($types as $type) {
|
| 92 |
$row = array();
|
| 93 |
$row[] = l($type['name'], 'admin/rpg/types/type/' . $type['type']);
|
| 94 |
$row[] = t('@desc', array('@desc' => $type['shortdesc']));
|
| 95 |
$actions = array();
|
| 96 |
$actions[] = l(t('edit'), 'admin/rpg/types/type/' . $type['type']);
|
| 97 |
$actions[] = l(t('delete'), 'admin/rpg/types/type/' . $type['type'] . '/delete');
|
| 98 |
$actions[] = l(t('attributes'), 'admin/rpg/types/type/' . $type['type'] . '/attributes');
|
| 99 |
$actions[] = l(t('actions'), 'admin/rpg/types/type/' . $type['type'] . '/actions');
|
| 100 |
$actions[] = l(t('events'), 'admin/rpg/types/type/' . $type['type'] . '/events');
|
| 101 |
$row[] = implode(', ', $actions);
|
| 102 |
$rows[] = $row;
|
| 103 |
}
|
| 104 |
$output .= theme('table', $header, $rows);
|
| 105 |
$output .= l(t('Add new RPG type'), 'admin/rpg/types/add');
|
| 106 |
return $output;
|
| 107 |
}
|
| 108 |
|
| 109 |
function theme_rpg_browse_page ($objects) {
|
| 110 |
$items = array();
|
| 111 |
foreach ($objects as $object) {
|
| 112 |
$object = rpg_object($object);
|
| 113 |
$name = rpg_get('name', $object->rid);
|
| 114 |
$items[] = l($name ? $name : $object->rid, 'rpg/view/' . $object->rid) . '<br />' . rpg_get('description', $object);
|
| 115 |
}
|
| 116 |
$output .= theme('item_list', $items);
|
| 117 |
$output .= theme('pager');
|
| 118 |
return $output;
|
| 119 |
}
|
| 120 |
|
| 121 |
/**
|
| 122 |
* This will display the intro text for rpg. In general, you should either override this theme function in your template.php file,
|
| 123 |
* or override the /rpg path entirely, pointing to your own node page, panel, view, or what have you.
|
| 124 |
*/
|
| 125 |
function theme_rpg_page() {
|
| 126 |
$output .= t('Welcome to Drupal RPG! Things are still in development, so !play at your own risk. If you are the administrator, you will probably want to create a new theme function to override this message. See the Drupal Handbook for more help.', array('!play' => l(t('play'), 'rpg/play')));
|
| 127 |
return $output;
|
| 128 |
}
|
| 129 |
|
| 130 |
function theme_rpg_get($property, $object) {
|
| 131 |
$args = func_get_args();
|
| 132 |
$attribute = rpg_object_attributes($object);
|
| 133 |
if ($attribute['theme']) {
|
| 134 |
$output = call_user_func_array('theme', array_merge(array($attribute['theme']), $args));
|
| 135 |
}
|
| 136 |
if (!$output) {
|
| 137 |
foreach (rpg_object_types($object) as $type) {
|
| 138 |
$output = call_user_func_array('theme', array_merge(array("rpg_get_type_{$type}_attribute_$property"), $args));
|
| 139 |
if ($output) {
|
| 140 |
break;
|
| 141 |
}
|
| 142 |
}
|
| 143 |
}
|
| 144 |
if (!$output) {
|
| 145 |
$output = call_user_func_array('theme', array_merge(array("rpg_get_attribute_$property"), $args));
|
| 146 |
}
|
| 147 |
if (!$output) {
|
| 148 |
$output = call_user_func_array('theme', array_merge(array('rpg_get_default'), $args));
|
| 149 |
}
|
| 150 |
return $output;
|
| 151 |
}
|
| 152 |
|
| 153 |
function theme_rpg_get_default($property, $object) {
|
| 154 |
$args = func_get_args();
|
| 155 |
return check_plain(call_user_func_array('rpg_get', $args));
|
| 156 |
}
|