| 1 |
<?php |
<?php |
| 2 |
// $Id$ |
// $Id: refcolab_collections.pages.inc,v 1.1 2008/06/13 02:36:19 herc Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 39 |
'#title' => t('Name'), |
'#title' => t('Name'), |
| 40 |
'#default_value' => $collection->name, |
'#default_value' => $collection->name, |
| 41 |
'#size' => 20, |
'#size' => 20, |
| 42 |
'#description' => t('The name of the collection.'), |
//'#description' => t('The name of the collection.'), |
| 43 |
); |
); |
| 44 |
$form['collection']['description'] = array( |
$form['collection']['description'] = array( |
| 45 |
'#type' => 'textfield', |
'#type' => 'textfield', |
| 46 |
'#title' => t('Description'), |
'#title' => t('Description'), |
| 47 |
'#default_value' => $collection->description, |
'#default_value' => $collection->description, |
| 48 |
'#size' => 30, |
'#size' => 30, |
| 49 |
'#description' => t('A brief description about what is this collection intended for.'), |
//'#description' => t('A brief description about what is this collection intended for.'), |
| 50 |
); |
); |
| 51 |
|
|
| 52 |
|
$tree = refcolab_collections_get_tree($collection->uid); |
| 53 |
|
|
| 54 |
|
// A collection can't be the child of itself, nor of its children. |
| 55 |
|
$exclude = array(); |
| 56 |
|
if ($collection->cid){ |
| 57 |
|
$children = refcolab_collections_get_tree($collection->uid, $collection->cid); |
| 58 |
|
foreach ($children as $child) { |
| 59 |
|
$exclude[] = $child->cid; |
| 60 |
|
} |
| 61 |
|
$exclude[] = $collection->cid; |
| 62 |
|
} |
| 63 |
|
|
| 64 |
|
if (count($tree)){ |
| 65 |
|
$form['collection']['parent'] = refcolab_collection_select($tree, t('Parent collection'), $collection->parent, $exclude); |
| 66 |
|
} |
| 67 |
|
|
| 68 |
$form['collection']['save'] = array( |
$form['collection']['save'] = array( |
| 69 |
'#type' => 'submit', |
'#type' => 'submit', |
| 70 |
'#value' => $collection->cid ? t('Save') : t('Add new'), |
'#value' => $collection->cid ? t('Save') : t('Add new'), |
| 155 |
$row = array( |
$row = array( |
| 156 |
theme('indentation', $form[$key]['#collection']->depth). |
theme('indentation', $form[$key]['#collection']->depth). |
| 157 |
drupal_render($form[$key]['name']). |
drupal_render($form[$key]['name']). |
| 158 |
' <span class="description">'. check_plain($form[$key]['name']['#description']). '</span>', |
'<span class="description">'. check_plain($form[$key]['name']['#description']). '</span>', |
| 159 |
|
|
| 160 |
drupal_render($form[$key]['cid']). |
drupal_render($form[$key]['cid']). |
| 161 |
drupal_render($form[$key]['parent']), |
drupal_render($form[$key]['parent']), |
| 171 |
|
|
| 172 |
$header = array(t('Collections'), '', t('Weight'), t('Operations')); |
$header = array(t('Collections'), '', t('Weight'), t('Operations')); |
| 173 |
$output = ''; |
$output = ''; |
|
$output .= drupal_render($form['new']); |
|
| 174 |
$output .= theme('table', $header, $rows, array('id' => 'collection-overview')); |
$output .= theme('table', $header, $rows, array('id' => 'collection-overview')); |
| 175 |
$output .= drupal_render($form); |
$output .= drupal_render($form); |
| 176 |
|
|
| 177 |
return $output; |
return $output; |
| 178 |
} |
} |
| 179 |
|
|
| 180 |
|
function theme_refcolab_collections_form($form){ |
| 181 |
|
drupal_add_css(drupal_get_path('module', 'refcolab_collections') .'/refcolab_collections.css', 'module', 'all', FALSE); |
| 182 |
|
|
| 183 |
|
$form['collection']['name']['#prefix'] = '<div class="refcolab-collection-left">'; |
| 184 |
|
$form['collection']['name']['#suffix'] = '</div>'; |
| 185 |
|
|
| 186 |
|
$form['collection']['description']['#prefix'] = '<div class="refcolab-collection-right">'; |
| 187 |
|
$form['collection']['description']['#suffix'] = '</div>'; |
| 188 |
|
|
| 189 |
|
$form['collection']['parent']['#prefix'] = '<div class="clear-block clear">'; |
| 190 |
|
$form['collection']['parent']['#suffix'] = '</div>'; |
| 191 |
|
|
| 192 |
|
return drupal_render($form); |
| 193 |
|
} |
| 194 |
|
|
| 195 |
function refcolab_collections_delete_confirm(&$form_state, $collection){ |
function refcolab_collections_delete_confirm(&$form_state, $collection){ |
| 196 |
$collection = (object)$collection; |
$collection = (object)$collection; |
| 197 |
$form['cid'] = array('#type' => 'hidden', '#value' => $collection->cid); |
$form['cid'] = array('#type' => 'hidden', '#value' => $collection->cid); |
| 208 |
} |
} |
| 209 |
|
|
| 210 |
function delete_submit($form, &$form_state) { |
function delete_submit($form, &$form_state) { |
| 211 |
db_query("DELETE FROM {refcolab_collections} WHERE cid = %d", $form['cid']); |
db_query("DELETE FROM {refcolab_collections} WHERE cid = %d", $form_state['values']['cid']); |
| 212 |
print_r($form['uid']); |
//print_r($form_state['values']['uid']); |
| 213 |
//$form_state['redirect'] = 'admin/content/collections/'.$form['uid']; |
$form_state['redirect'] = 'admin/content/collections/'.$form_state['values']['uid']; |
| 214 |
|
drupal_set_message('The collection has been deleted'); |
| 215 |
return; |
return; |
| 216 |
} |
} |