View source
<?php
$plugin = array(
'single' => TRUE,
'title' => t('Create content'),
'defaults' => array(
'types' => NULL,
),
'icon' => 'cog.png',
'description' => t('Provides links to create new content.'),
'category' => t('Dashboard'),
'edit text' => t('Configure'),
);
function total_control_create_content_type_admin_title($subtype = NULL, $conf = NULL, $context = NULL) {
return t('Content creation links');
}
function total_control_create_content_type_admin_info($subtype = NULL, $conf = NULL, $context = NULL) {
$block = new stdClass();
$block->title = t('Provides links to create new content.');
return $block;
}
function total_control_create_content_type_render($subtype, $conf, $panel_args, &$context) {
$block = new stdClass();
$block->module = t('total_control');
$block->title = t('Create content');
$types = node_type_get_types();
$create = array();
foreach ($types as $type => $object) {
if (!array_key_exists($type, $conf['types']) || isset($conf['types']) && $conf['types'][$type]) {
if (node_access('create', $type)) {
$type_url_str = str_replace('_', '-', $object->type);
$create[] = l(t('Add new ' . $object->name), 'node/add/' . $type_url_str);
}
}
}
$block->content = theme('total_control_create', array(
'create' => $create,
));
return $block;
}
function total_control_create_content_type_edit_form($form, &$form_state) {
$conf = $form_state['conf'];
$types = node_type_get_types();
$type_options = array();
$type_defaults = array();
if (isset($conf['types'])) {
$type_defaults = $conf['types'];
}
foreach ($types as $type => $object) {
$type_options[$type] = $object->name;
if (!array_key_exists($type, $type_defaults)) {
$type_defaults[$type] = $type;
}
}
$form['types'] = array(
'#type' => 'checkboxes',
'#title' => t('Include Create links for Content Types'),
'#options' => $type_options,
'#default_value' => $type_defaults,
);
return $form;
}
function total_control_create_content_type_edit_form_submit($form, &$form_state) {
foreach (array_keys($form_state['plugin']['defaults']) as $key) {
$form_state['conf'][$key] = $form_state['values'][$key];
}
}