function img_assist_header_form in Image Assist 5.2
Same name and namespace in other branches
- 5.3 img_assist.module \img_assist_header_form()
- 5 img_assist.module \img_assist_header_form()
- 6.2 img_assist.module \img_assist_header_form()
- 6 img_assist.module \img_assist_header_form()
Related topics
1 string reference to 'img_assist_header_form'
File
- ./
img_assist.module, line 594 - Image Assist module
Code
function img_assist_header_form($mode) {
global $user;
// Upload image.
if ($mode == 'uploading') {
$form[] = array(
'#value' => '<div id="header-uploading">',
);
$form[] = array(
'#value' => '<strong>' . t('Upload: ') . '</strong>' . t('Fill in the form below to upload a new image.'),
);
$form[] = array(
'#value' => '</div><div id="header-startover">',
);
$form['startover'] = array(
'#type' => 'button',
'#value' => t('Start Over'),
'#button_type' => 'button',
'#attributes' => array(
'onclick' => 'parent.onClickStartOver();',
),
);
$form[] = array(
'#value' => '</div>',
);
}
elseif ($mode == 'properties') {
$form[] = array(
'#value' => '<div id="header-properties">',
);
$form[] = array(
'#value' => '<strong>' . t('Properties: ') . '</strong>' . t('Change how the image is displayed.'),
);
$form[] = array(
'#value' => '</div><div id="header-startover">',
);
$form['startover'] = array(
'#type' => 'button',
'#value' => t('Start Over'),
'#button_type' => 'button',
'#attributes' => array(
'onclick' => 'parent.onClickStartOver()',
),
);
$form[] = array(
'#value' => '</div>',
);
}
else {
$form[] = array(
'#value' => '<div id="header-browse">',
);
$form[] = array(
'#value' => '<strong>' . t('Browse Images: ') . '</strong>',
);
// Get my images and count.
$result = db_query("SELECT COUNT(n.nid) FROM {node} n WHERE n.type='image' AND n.uid= %d", $user->uid);
$count = $result ? db_result($result, 0) : 0;
$options['myimages'] = t('My Images') . " ({$count})";
// Get all images and count.
// Count all published images and the user's unpublished images.
if (user_access('access all images')) {
$result = db_query("SELECT COUNT(n.nid) FROM {node} n WHERE n.type='image' AND (n.uid = %d OR n.status = 1)", $user->uid);
$count = $result ? db_result($result, 0) : 0;
$options['allimages'] = t('All Images') . " ({$count})";
}
// Get category list.
if (module_exists('taxonomy')) {
$vocabs = (array) variable_get('img_assist_vocabs', array());
foreach ($vocabs as $vid) {
$vocab = taxonomy_get_vocabulary($vid);
$terms = taxonomy_get_tree($vid);
if ($terms) {
foreach ($terms as $key => $value) {
$tid = $value->tid;
$name = $value->name;
// For this term, count all published images and the user's
// unpublished images.
if (user_access('access all images')) {
$result = db_query("SELECT COUNT(n.nid) FROM {node} n, {term_node} t WHERE t.nid=n.nid AND n.type='image' AND t.tid = %d AND (n.uid = %d OR n.status = 1)", $tid, $user->uid);
}
else {
$result = db_query("SELECT COUNT(n.nid) FROM {node} n, {term_node} t WHERE t.nid=n.nid AND n.type='image' AND t.tid = %d AND n.uid = %d", $tid, $user->uid);
}
$count = $result ? db_result($result, 0) : 0;
if ($count) {
$options[$vocab->name][$tid] = $name . " ({$count})";
}
}
}
}
}
$form['browse'] = array(
'#type' => 'select',
'#default_value' => 'myimages',
'#options' => $options,
'#attributes' => array(
'onchange' => 'parent.onChangeBrowseBy(this)',
),
);
if (user_access('create images')) {
$form['upload'] = array(
'#type' => 'button',
'#prefix' => ' ' . t('or') . ' ',
'#value' => t('Upload'),
'#suffix' => ' ' . t('a new image'),
'#button_type' => 'button',
'#attributes' => array(
'onclick' => 'parent.onClickUpload()',
),
);
}
$form[] = array(
'#value' => '</div><div id="header-cancel">',
);
$form['cancel'] = array(
'#type' => 'button',
'#value' => t('Cancel'),
'#button_type' => 'button',
'#attributes' => array(
'onclick' => 'parent.cancelAction()',
),
);
$form[] = array(
'#value' => '</div>',
);
}
return $form;
}