function ad_channel_admin_channel in Advertisement 6.2
Same name and namespace in other branches
- 5.2 channel/ad_channel.module \ad_channel_admin_channel()
- 6.3 channel/ad_channel.module \ad_channel_admin_channel()
- 7 channel/ad_channel.module \ad_channel_admin_channel()
Administrative page for creating or editing channels.
1 string reference to 'ad_channel_admin_channel'
- ad_channel_menu in channel/
ad_channel.module - Implementation of hook_menu.
File
- channel/
ad_channel.module, line 1052 - Ad Channel module.
Code
function ad_channel_admin_channel($form_state, $chid = 0) {
$form = array();
if ($chid) {
$channel = _ad_channel_get_channels($chid);
if (empty($channel)) {
drupal_goto('admin/content/ad/channel');
}
$form['chid'] = array(
'#type' => 'hidden',
'#value' => $chid,
);
}
$form['name'] = array(
'#type' => 'textfield',
'#required' => TRUE,
'#title' => t('Channel name'),
'#description' => t('Enter a short, descriptive name for your channel.'),
'#default_value' => $chid ? $channel->name : '',
);
$form['description'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#description' => t('Enter a full description of your channel.'),
'#default_value' => $chid ? $channel->description : '',
);
$result = db_query('SELECT conid, name FROM {ad_channel_container} ORDER BY weight ASC');
$containers = array(
t('<none>'),
);
while ($container = db_fetch_object($result)) {
$containers[$container->conid] = $container->name;
}
if (sizeof($containers) == 1) {
$containers = array(
t('No containers have been created.'),
);
}
$form['conid'] = array(
'#type' => 'select',
'#title' => t('Container'),
'#options' => $containers,
'#description' => t('Optionally assign your channel to a container. Containers can be used to help organize your channels, but they are not required.'),
'#default_value' => $chid ? $channel->conid : 0,
);
$form['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
'#description' => t('When listing channels, those with the lighter (smaller) weights get listed before channels with heavier (larger) weights. Channels with equal weights are sorted alphabetically.'),
'#default_value' => $chid ? $channel->weight : 0,
);
// Inventory for remnant management
$form['channel_inventory'] = array(
'#type' => 'fieldset',
'#title' => t('Inventory'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['channel_inventory']['inventory'] = array(
'#type' => 'textfield',
'#title' => t('Level'),
'#size' => 10,
'#maxlength' => 10,
'#required' => FALSE,
'#description' => t('Entering an inventory value will limit the number of advertisements that may be assigned to this channel. As well, if fewer advertisements than the inventory value are assigned to this channel, advertisements marked as remnants will be used to reach the assigned inventory level.'),
'#default_value' => $chid ? $channel->inventory : 0,
);
// URL rules
$form['URL_rules'] = array(
'#type' => 'fieldset',
'#title' => t('URL rules'),
'#collapsible' => TRUE,
'#collasped' => FALSE,
);
$form['URL_rules']['display'] = array(
'#type' => 'radios',
'#title' => t('Display advertisements from this channel on specific URLs'),
'#options' => array(
t('Display advertisements on every URL except the listed URLs.'),
t('Display advertisements only on the listed URLs.'),
),
'#default_value' => $chid ? $channel->display : 0,
);
$form['URL_rules']['urls'] = array(
'#type' => 'textarea',
'#title' => t('Paths'),
'#description' => t("Enter one URL per line. If serving ads locally use Drupal relative paths. If serving ads remotely include the 'http://' or 'https:/'. Use '<front>' to specify the front page. The '*' character is a wildcard. Example URLs are <em>blog</em> for the blog page and <em>blog/*</em> for every personal blog on your local website."),
'#default_value' => $chid ? unserialize($channel->urls) : '',
);
// Group rules
$groups = taxonomy_get_tree(_ad_get_vid());
$collapsed = is_array($groups) && !empty($groups) ? FALSE : TRUE;
$form['group_rules'] = array(
'#type' => 'fieldset',
'#title' => t('Ad group rules'),
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
);
if (!$collapsed) {
foreach ($groups as $group) {
$options[$group->tid] = $group->name;
}
$form['group_rules']['groups'] = array(
'#type' => 'checkboxes',
'#title' => t('Allow advertisements from specific ad groups'),
'#options' => $options,
'#prefix' => '<div>',
'#suffix' => '</div>',
'#description' => t('By selecting one or more groups, only advertisements from the selected group(s) will be allowed to be added to this channel. If no groups are selected, any advertisement can be added to this channel regardless of its group.'),
'#default_value' => $chid ? unserialize($channel->groups) : array(),
);
}
else {
$form['group_rules']['none'] = array(
'#type' => 'markup',
'#value' => t('No ad groups have been created.'),
'#prefix' => '<div>',
'#suffix' => '</div>',
);
}
$collapsed = variable_get('ad_channel_display', 0) == 1 ? 0 : 1;
$form['nonchannel_rules'] = array(
'#type' => 'fieldset',
'#title' => t('Not-in-channel ad rules'),
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
);
if ($collapsed) {
$form['nonchannel_rules']['info'] = array(
'#type' => 'markup',
'#prefix' => '<div>',
'#suffix' => '</div>',
'#value' => t('You will need to set "!variable" to %value for these %type ad rules to be applicable. Currently these settings are doing nothing.', array(
'!variable' => l(t('display advertisements not assigned to any channel'), 'admin/content/ad/channel/settings'),
'%value' => t('always'),
'%type' => 'not-in-channel',
)),
);
}
$form['nonchannel_rules']['no_channel_percent'] = array(
'#type' => 'select',
'#title' => t('Percentage'),
'#options' => _ad_channel_percentages(),
'#default_value' => $chid ? $channel->no_channel_percent : 10,
'#description' => t('Choose the maximum percentage of not-in-channel advertisements allowable for display. For instance, selecting 10% indicates that 1 out of 10 advertisements will be selected from those not assigned to this channel.'),
);
if ($chid) {
$form['update'] = array(
'#type' => 'submit',
'#value' => t('Update'),
);
$form['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
);
}
else {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Create'),
);
}
$form['cancel'] = array(
'#type' => 'markup',
'#value' => l(t('Cancel'), 'admin/content/ad/channel'),
);
return $form;
}