function tag_image() { global $step, $endform, $tag_name, $img_dir; $atts = gpsa(array('class', 'escape', 'html_id', 'style', 'wraptag', 'alt', 'caption', 'h', 'id', 'w')); extract($atts); $ext = gps('ext'); $type = gps('type'); $types = array('textile' => 'Textile', 'textpattern' => 'Textpattern', 'xhtml' => 'XHTML'); $out = form(startTable('tagbuilder') . tr(tdcs(hed(gTxt('tag_' . $tag_name), 3), 2)) . tagRow('type', '' . selectInput('type', $types, $type ? $type : 'textpattern', true)) . tagRow('escape', escape_pop($escape)) . tagRow('html_id', fInput('text', 'html_id', $html_id, 'edit', '', '', 25)) . tagRow('class', fInput('text', 'class', $class, 'edit', '', '', 25)) . tagRow('inline_style', fInput('text', 'style', $style, 'edit', '', '', 25)) . tagRow('wraptag', fInput('text', 'wraptag', $wraptag, 'edit', '', '', 25)) . hInput('id', $id) . hInput('ext', $ext) . hInput('w', $w) . hInput('h', $h) . hInput('alt', $alt) . hInput('caption', $caption) . $endform); if ($step == 'build') { if ($escape == 'html') { $alt = str_replace('&', '&', htmlspecialchars($alt)); $caption = str_replace('&', '&', htmlspecialchars($caption)); } $url = imagesrcurl($id, $ext); switch ($type) { case 'textile': $alt = $alt ? ' (' . $alt . ')' : ''; $modifiers = ''; if ($class) { $modifiers .= '(' . $class; if ($html_id) { $modifiers .= '#' . $html_id; } $modifiers .= ')'; } elseif ($html_id) { $modifiers .= "(#{$html_id})"; } if ($style) { $modifiers .= '{' . $style . '}'; } $wraptag = $wraptag ? $wraptag . $modifiers . '. ' : ''; $out .= tdb(($wraptag ? $wraptag : '') . '!' . ($wraptag ? '' : $modifiers) . $url . $alt . '!'); break; case 'xhtml': $alt = ' alt="' . $alt . '"'; $caption = $caption ? ' title="' . $caption . '"' : ''; $class = $class ? ' class="' . $class . '"' : ''; $html_id = $html_id ? ' id="' . $html_id . '"' : ''; $style = $style ? ' style="' . $style . '"' : ''; $out .= tdb(($wraptag ? "<{$wraptag}>" : '') . '<img src="' . $url . '" width="' . $w . '" height="' . $h . '"' . $alt . $caption . $html_id . $class . $style . ' />' . ($wraptag ? "</{$wraptag}>" : '')); break; case 'textpattern': default: $atts = array('class' => $class, 'html_id' => $html_id, 'id' => $id, 'style' => $style, 'wraptag' => $wraptag); $out .= tdb(tb($tag_name, $atts)); break; } } return $out; }
function image_edit($message = '', $id = '') { global $prefs, $file_max_upload_size, $txp_user, $event, $all_image_cats; if (!$id) { $id = gps('id'); } $id = assert_int($id); $rs = safe_row("*, unix_timestamp(date) as uDate", "txp_image", "id = {$id}"); if ($rs) { extract($rs); if (!has_privs('image.edit') && !($author === $txp_user && has_privs('image.edit.own'))) { image_list(gTxt('restricted_area')); return; } pagetop(gTxt('edit_image'), $message); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if ($ext != '.swf') { $aspect = $h == $w ? ' square' : ($h > $w ? ' portrait' : ' landscape'); $img_info = $id . $ext . ' (' . $w . ' × ' . $h . ')'; $img = '<div class="fullsize-image"><img class="content-image" src="' . imagesrcurl($id, $ext) . "?{$uDate}" . '" alt="' . $img_info . '" title="' . $img_info . '" /></div>'; } else { $img = $aspect = ''; } if ($thumbnail and $ext != '.swf') { $thumb_info = $id . 't' . $ext . ' (' . $thumb_w . ' × ' . $thumb_h . ')'; $thumb = '<img class="content-image" src="' . imagesrcurl($id, $ext, true) . "?{$uDate}" . '" alt="' . $thumb_info . '" ' . ($thumb_w ? 'width="' . $thumb_w . '" height="' . $thumb_h . '" title="' . $thumb_info . '"' : '') . ' />'; } else { $thumb = ''; if ($thumb_w == 0) { $thumb_w = get_pref('thumb_w', 0); } if ($thumb_h == 0) { $thumb_h = get_pref('thumb_h', 0); } } echo n . '<div id="' . $event . '_container" class="txp-container">'; echo pluggable_ui('image_ui', 'fullsize_image', $img, $rs), '<section class="txp-edit">', hed(gTxt('edit_image'), 2), pluggable_ui('image_ui', 'image_edit', wrapGroup('image_edit_group', upload_form('', '', 'image_replace', 'image', $id, $file_max_upload_size, 'image_replace', 'image-replace'), 'replace_image', 'replace-image', 'replace_image_form'), $rs), pluggable_ui('image_ui', 'thumbnail_image', '<div class="thumbnail-edit">' . ($thumbnail ? $thumb . n . dLink('image', 'thumbnail_delete', 'id', $id, '', '', '', '', array($page, $sort, $dir, $crit, $search_method)) : '') . '</div>', $rs), pluggable_ui('image_ui', 'thumbnail_edit', wrapGroup('thumbnail_edit_group', upload_form('', '', 'thumbnail_insert', 'image', $id, $file_max_upload_size, 'upload_thumbnail', 'thumbnail-upload'), 'upload_thumbnail', 'thumbnail-upload', 'upload_thumbnail'), $rs), check_gd($ext) ? pluggable_ui('image_ui', 'thumbnail_create', wrapGroup('thumbnail_create_group', form(graf(n . '<label for="width">' . gTxt('thumb_width') . '</label>' . fInput('text', 'width', @$thumb_w, 'input-xsmall', '', '', INPUT_XSMALL, '', 'width') . n . '<label for="height">' . gTxt('thumb_height') . '</label>' . fInput('text', 'height', @$thumb_h, 'input-xsmall', '', '', INPUT_XSMALL, '', 'height') . n . '<label for="crop">' . gTxt('keep_square_pixels') . '</label>' . checkbox('crop', 1, @$prefs['thumb_crop'], '', 'crop') . fInput('submit', '', gTxt('Create')), ' class="edit-alter-thumbnail"') . hInput('id', $id) . eInput('image') . sInput('thumbnail_create') . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('search_method', $search_method) . hInput('crit', $crit), '', '', 'post', 'edit-form', '', 'thumbnail_alter_form'), 'create_thumbnail', 'thumbnail-alter', 'create_thumbnail'), $rs) : '', '<div class="image-detail">', form(inputLabel('image_name', fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'image_name'), 'image_name') . inputLabel('image_category', treeSelectInput('category', $all_image_cats, $category, 'image_category'), 'image_category') . inputLabel('image_alt_text', fInput('text', 'alt', $alt, '', '', '', INPUT_REGULAR, '', 'image_alt_text'), 'alt_text') . inputLabel('image_caption', text_area('caption', 0, 0, $caption, 'image_caption', TEXTAREA_HEIGHT_SMALL, INPUT_LARGE), 'caption', '', '', '') . pluggable_ui('image_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('save'), 'publish')) . hInput('id', $id) . eInput('image') . sInput('image_save') . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('search_method', $search_method) . hInput('crit', $crit), '', '', 'post', 'edit-form', '', 'image_details_form'), '</div>', '</section>' . n . '</div>'; } }
/** * Tag builder <txp:image> tag. */ function tag_image() { global $step; $atts = gpsa(array('class', 'html_id', 'style', 'wraptag', 'alt', 'caption', 'h', 'id', 'w', 'ext', 'type')); extract($atts); $types = array('textile' => 'Textile', 'textpattern' => 'Textpattern', 'html' => 'HTML'); $out = $this->tagbuildForm($this->startblock . $this->widgets(array('type' => '' . selectInput('type', $types, $type ? $type : 'textpattern', false, '', 'type'), 'html_id' => $this->tbInput('html_id', $html_id, INPUT_REGULAR), 'class' => $this->tbInput('class', $class, INPUT_REGULAR), 'inline_style' => $this->tbInput('style', $style, INPUT_REGULAR, 'inline_style'), 'wraptag' => $this->tbInput('wraptag', $wraptag))) . hInput('id', $id) . hInput('ext', $ext) . hInput('w', $w) . hInput('h', $h) . hInput('alt', $alt) . hInput('caption', $caption) . $this->endform); if ($step === 'build') { $url = imagesrcurl($id, $ext); switch ($type) { case 'textile': $alternate = $alt ? ' (' . $alt . ')' : ''; $modifiers = ''; if ($class) { $modifiers .= '(' . $class; if ($html_id) { $modifiers .= '#' . $html_id; } $modifiers .= ')'; } elseif ($html_id) { $modifiers .= "(#{$html_id})"; } if ($style) { $modifiers .= '{' . $style . '}'; } $wrap = $wraptag ? $wraptag . $modifiers . '. ' : ''; $out .= $this->tdb(($wrap ? $wrap : '') . '!' . ($wrap ? '' : $modifiers) . $url . $alternate . '!'); break; case 'html': $alternate = ' alt="' . txpspecialchars($alt) . '"'; $cap = $caption ? ' title="' . txpspecialchars($caption) . '"' : ''; $cls = $class ? ' class="' . $class . '"' : ''; $htmlid = $html_id ? ' id="' . $html_id . '"' : ''; $inlinestyle = $style ? ' style="' . $style . '"' : ''; $out .= $this->tdb(($wraptag ? "<{$wraptag}>" : '') . '<img src="' . $url . '" width="' . $w . '" height="' . $h . '"' . $alternate . $cap . $htmlid . $cls . $inlinestyle . ' />' . ($wraptag ? "</{$wraptag}>" : '')); break; case 'textpattern': default: $atts = array('class' => $class, 'html_id' => $html_id, 'id' => $id, 'style' => $style, 'wraptag' => $wraptag); $out .= $this->build($atts); break; } } return $out; }
function image_edit($message = '', $id = '') { global $txpcfg, $img_dir, $file_max_upload_size, $txp_user, $event; if (!$id) { $id = gps('id'); } $id = assert_int($id); $rs = safe_row("*, unix_timestamp(date) as uDate", "txp_image", "id = {$id}"); if ($rs) { extract($rs); if (!has_privs('image.edit') && !($author == $txp_user && has_privs('image.edit.own'))) { image_list(gTxt('restricted_area')); return; } pagetop(gTxt('edit_image'), $message); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); $categories = getTree("root", "image"); if ($ext != '.swf') { $aspect = $h == $w ? ' square' : ($h > $w ? ' portrait' : ' landscape'); $img = '<img class="image fullsize" src="' . imagesrcurl($id, $ext) . "?{$uDate}" . '" height="' . $h . '" width="' . $w . '" alt="" title="' . $id . $ext . ' (' . $w . ' × ' . $h . ')" id="image-fullsize" />'; } else { $img = $aspect = ''; } if ($thumbnail and $ext != '.swf') { $thumb = '<img class="image thumbnail" src="' . imagesrcurl($id, $ext, true) . "?{$uDate}" . '" alt="" ' . ($thumb_w ? "width='{$thumb_w}' height='{$thumb_h}'" : '') . ' />'; } else { $thumb = ''; } echo n . '<div id="' . $event . '_container" class="txp-container txp-edit">'; echo startTable('list', '', 'edit-pane'), tr(td(pluggable_ui('image_ui', 'image_edit', $img . br . upload_form(gTxt('replace_image'), 'replace_image_form', 'image_replace', 'image', $id, $file_max_upload_size, 'image-replace', 'image-replace'), $rs)), ' class="image-edit' . $aspect . '"'), tr(td(pluggable_ui('image_ui', 'thumbnail_edit', join('', array($thumbnail ? startTable('image-thumbnail', '', 'image-thumbnail') . tr(td($thumb, '', 'thumbwrapper') . td(dLink('image', 'thumbnail_delete', 'id', $id, '', '', '', '', array($page, $sort, $dir, $crit, $search_method)))) . endTable() . br : '', upload_form(gTxt('upload_thumbnail'), 'upload_thumbnail', 'thumbnail_insert', 'image', $id, $file_max_upload_size, 'upload-thumbnail', 'thumbnail-upload'))), $rs)), ' class="thumbnail-edit"'), check_gd($ext) ? thumb_ui($id, $rs) : '', tr(td(form(graf('<label for="image-name">' . gTxt('image_name') . '</label>' . br . fInput('text', 'name', $name, 'edit', '', '', '', '', 'image-name'), ' class="name"') . graf('<label for="image-category">' . gTxt('image_category') . '</label>' . br . treeSelectInput('category', $categories, $category, 'image-category'), ' class="category"') . graf('<label for="alt-text">' . gTxt('alt_text') . '</label>' . br . fInput('text', 'alt', $alt, 'edit', '', '', 50, '', 'alt-text'), ' class="alt text"') . graf('<label for="caption">' . gTxt('caption') . '</label>' . br . '<textarea id="caption" name="caption">' . $caption . '</textarea>', ' class="caption description text"') . pluggable_ui('image_ui', 'extend_detail_form', '', $rs) . n . graf(fInput('submit', '', gTxt('save'), 'publish')) . n . hInput('id', $id) . n . eInput('image') . n . sInput('image_save') . n . hInput('sort', $sort) . n . hInput('dir', $dir) . n . hInput('page', $page) . n . hInput('search_method', $search_method) . n . hInput('crit', $crit), '', '', 'post', 'edit-form', '', 'image_details_form')), ' class="image-detail"'), endTable() . n . '</div>'; } }
function image_url($atts, $thing = NULL) { global $thisimage; extract(lAtts(array('name' => '', 'id' => '', 'thumbnail' => 0, 'link' => 'auto'), $atts)); $from_form = false; if ($id) { $thisimage = imageFetchInfo('id = ' . intval($id)); } elseif ($name) { $thisimage = imageFetchInfo("name = '" . doSlash($name) . "'"); } else { assert_image(); $from_form = true; } if ($thisimage) { $url = imagesrcurl($thisimage['id'], $thisimage['ext'], $thumbnail); $link = $link == 'auto' ? $thing ? 1 : 0 : $link; $out = $thing ? parse($thing) : $url; $out = $link ? href($out, $url) : $out; if (!$from_form) { $thisimage = ''; } return $out; } return ''; }
/** * Renders and outputs the image editor panel. * * @param string|array $message The activity message * @param int $id The image ID */ function image_edit($message = '', $id = '') { global $prefs, $file_max_upload_size, $txp_user, $event, $all_image_cats; if (!$id) { $id = gps('id'); } $id = assert_int($id); $rs = safe_row("*, UNIX_TIMESTAMP(date) AS uDate", 'txp_image', "id = {$id}"); if ($rs) { extract($rs); if (!has_privs('image.edit') && !($author === $txp_user && has_privs('image.edit.own'))) { image_list(gTxt('restricted_area')); return; } pagetop(gTxt('edit_image'), $message); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if ($ext != '.swf') { $aspect = $h == $w ? ' square' : ($h > $w ? ' portrait' : ' landscape'); $img_info = $id . $ext . ' (' . $w . ' × ' . $h . ')'; $img = '<div class="fullsize-image"><img class="content-image" src="' . imagesrcurl($id, $ext) . "?{$uDate}" . '" alt="' . $img_info . '" title="' . $img_info . '" /></div>'; } else { $img = $aspect = ''; } if ($thumbnail and $ext != '.swf') { $thumb_info = $id . 't' . $ext . ' (' . $thumb_w . ' × ' . $thumb_h . ')'; $thumb = '<img class="content-image" src="' . imagesrcurl($id, $ext, true) . "?{$uDate}" . '" alt="' . $thumb_info . '" title="' . $thumb_info . '" />'; } else { $thumb = ''; if ($thumb_w == 0) { $thumb_w = get_pref('thumb_w', 0); } if ($thumb_h == 0) { $thumb_h = get_pref('thumb_h', 0); } } $imageBlock = array(); $thumbBlock = array(); $imageBlock[] = pluggable_ui('image_ui', 'fullsize_image', $img, $rs); $imageBlock[] = pluggable_ui('image_ui', 'image_edit', upload_form('replace_image', 'replace_image_form', 'image_replace', 'image', $id, $file_max_upload_size, 'image-upload', ' image-replace'), $rs); $thumbBlock[] = hed(gTxt('create_thumbnail') . popHelp('create_thumbnail'), 3); $thumbBlock[] = check_gd($ext) ? pluggable_ui('image_ui', 'thumbnail_create', form(graf(n . '<label for="width">' . gTxt('thumb_width') . '</label>' . fInput('text', 'width', @$thumb_w, 'input-xsmall', '', '', INPUT_XSMALL, '', 'width') . n . '<label for="height">' . gTxt('thumb_height') . '</label>' . fInput('text', 'height', @$thumb_h, 'input-xsmall', '', '', INPUT_XSMALL, '', 'height') . n . '<label for="crop">' . gTxt('keep_square_pixels') . '</label>' . checkbox('crop', 1, @$prefs['thumb_crop'], '', 'crop') . fInput('submit', '', gTxt('create')), ' class="edit-alter-thumbnail"') . hInput('id', $id) . eInput('image') . sInput('thumbnail_create') . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('search_method', $search_method) . hInput('crit', $crit), '', '', 'post', '', '', 'thumbnail_alter_form'), $rs) : ''; $thumbBlock[] = pluggable_ui('image_ui', 'thumbnail_image', '<div class="thumbnail-image">' . ($thumbnail ? $thumb . n . dLink('image', 'thumbnail_delete', 'id', $id, '', '', '', '', array($page, $sort, $dir, $crit, $search_method)) : '') . '</div>', $rs); $thumbBlock[] = pluggable_ui('image_ui', 'thumbnail_edit', upload_form('upload_thumbnail', 'upload_thumbnail', 'thumbnail_insert', 'image', $id, $file_max_upload_size, 'thumbnail-upload', ' thumbnail-upload'), $rs); echo n . tag(hed(gTxt('edit_image'), 1, array('class' => 'txp-heading')) . n . implode(n, $imageBlock) . '<hr />' . tag(implode(n, $thumbBlock), 'section', array('class' => 'thumbnail-alter')), 'div', array('class' => 'txp-layout-4col-cell-1-2-3')) . '<div class="txp-layout-4col-cell-4alt">', form(graf(fInput('submit', '', gTxt('save'), 'publish'), array('class' => 'txp-save')) . wrapGroup('image-details', inputLabel('image_name', fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'image_name'), 'image_name', '', array('class' => 'txp-form-field edit-image-name')) . inputLabel('image_category', event_category_popup('image', $category, 'image_category') . n . eLink('category', 'list', '', '', gTxt('edit'), '', '', '', 'txp-option-link'), 'image_category', '', array('class' => 'txp-form-field edit-image-category')) . inputLabel('image_alt_text', fInput('text', 'alt', $alt, '', '', '', INPUT_REGULAR, '', 'image_alt_text'), 'alt_text', '', array('class' => 'txp-form-field edit-image-alt-text')) . inputLabel('image_caption', '<textarea id="image_caption" name="caption" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '">' . $caption . '</textarea>', 'caption', '', array('class' => 'txp-form-field txp-form-field-textarea edit-image-caption')) . pluggable_ui('image_ui', 'extend_detail_form', '', $rs) . hInput('id', $id) . eInput('image') . sInput('image_save') . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('search_method', $search_method) . hInput('crit', $crit), 'image_details'), '', '', 'post', '', '', 'image_details_form'), '</div>'; } }