80c80 < global $img_dir; --- > global $img_dir, $thisimage; 128a129,135 > elseif ($thisimage) > { > $id = (int) $thisimage['id']; > > $rs = safe_row('*', 'txp_image', "id = $id limit 1"); > } > 163c170 < global $img_dir; --- > global $img_dir, $thisimage; 192a200,206 > elseif ($thisimage) > { > $id = (int) $thisimage['id']; > > $rs = safe_row('*', 'txp_image', "id = $id limit 1"); > } > 238a253,277 > > > // ------------------------------------------------------------- > function imageFetchInfo($where) > { > $rs = safe_row('*', 'txp_image', $where); > > if ($rs) > { > return image_format_info($rs); > } > > return false; > } > > //-------------------------------------------------------------------------- > function image_format_info($image) > { > if (($unix_ts = @strtotime($image['date'])) > 0) > $image['date'] = $unix_ts; > > return $image; > } > > 2317a2357,2627 > function image_list($atts, $thing = '') > { > global $s,$c,$p,$img_dir,$path_to_site, $thisimage; > > extract(lAtts(array( > 'label' => '', > 'break' => br, > 'wraptag' => '', > 'class' => __FUNCTION__, > 'labeltag' => '', > 'category' => '', > 'has_thumb' => 0, > 'form' => '', > 'thumb' => 0, > 'limit' => 0, > 'offset' => 0, > 'sort' => 'name ASC', > ),$atts)); > > $where = array(); > $has_content = $thing || $form; > if ($category) $where[] = "category IN ('".join("','", doSlash(do_list($category)))."')"; > if ($has_thumb) $where[] = "thumbnail = 1"; > > $qparts = array( > join(' AND ', $where), > 'order by '.doSlash($sort), > ($limit) ? 'limit '.intval($offset).', '.intval($limit) : '' > ); > > $rs = safe_rows_start('*', 'txp_image', join(' ', $qparts)); > > if ($rs) { > $out = array(); > while ($a = nextRow($rs)) { > $thisimage = image_format_info($a); > if (!$has_content) { > $url = pagelinkurl(array('c'=>$thisimage['category'], 's'=>$s, 'p'=>$thisimage['id'])); > $src = ($thumb) ? image_url(array('thumb' => '1')) : image_url(array()); > $dims = ($thumb) ? image_size(array('thumb' => '1', 'as_html' => '1')) : image_size(array('as_html' => '1')); > $thing = ''. > ''.$thisimage['alt'].''.''.n; > } > $out[] = ($thing) ? parse($thing) : parse_form($form); > } > $thisimage = ''; > if ($out) { > return doLabel($label, $labeltag).doWrap($out, $wraptag, $break, $class); > } > } > return ''; > } > > //-------------------------------------------------------------------------- > > function image_name() > { > global $thisimage; > assert_image(); > return $thisimage['name']; > } > > //-------------------------------------------------------------------------- > > function image_category($atts) > { > global $thisimage; > assert_image(); > > extract(lAtts(array( > 'class' => '', > 'title' => 0, > 'wraptag' => '', > ), $atts)); > > if ($thisimage['category']) > { > $category = ($title) ? > fetch_category_title($thisimage['category'], 'image') : > $thisimage['category']; > > return ($wraptag) ? doTag($category, $wraptag, $class) : $category; > } > } > > //-------------------------------------------------------------------------- > > function image_url($atts) > { > global $thisimage, $img_dir; > assert_image(); > > extract(lAtts(array( > 'thumb' => 0, > ), $atts)); > > return hu.$img_dir.'/'.$thisimage['id'].(($thumb) ? 't' : '').$thisimage['ext']; > } > > //-------------------------------------------------------------------------- > > function image_size($atts) > { > global $thisimage, $path_to_site, $img_dir; > assert_image(); > > extract(lAtts(array( > 'type' => 'width, height', > 'as_html' => 0, > 'thumb' => 0, > 'join' => ' ', > ), $atts)); > > $join = ($as_html) ? ' ' : $join; > $type = do_list($type); > > if ($thumb) > { > $thumbpath = $img_dir.'/'.$thisimage['id'].'t'.$thisimage['ext']; > $thumbinfo = @getimagesize($path_to_site.'/'.$thumbpath); > $width = (isset($thumbinfo[0])) ? $thumbinfo[0] : ''; > $height = (isset($thumbinfo[1])) ? $thumbinfo[1] : ''; > } > > else > { > $width = $thisimage['w']; > $height = $thisimage['h']; > } > > $out = array(); > foreach ($type as $dim) { > if ($dim == "width") { > $out[] = ($as_html) ? 'width="'.$width.'"' : $width; > } > if ($dim == "height") { > $out[] = ($as_html) ? 'height="'.$height.'"' : $height; > } > } > return join($join, $out); > } > > //-------------------------------------------------------------------------- > > function image_alt($atts) > { > global $thisimage; > assert_image(); > > extract(lAtts(array( > 'class' => '', > 'escape' => 'html', > 'wraptag' => '', > ), $atts)); > > if ($thisimage['alt']) > { > $alt = ($escape == 'html') ? > htmlspecialchars($thisimage['alt']) : $thisimage['alt']; > > return ($wraptag) ? doTag($alt, $wraptag, $class) : $alt; > } > } > > //-------------------------------------------------------------------------- > > function image_caption($atts) > { > global $thisimage; > assert_image(); > > extract(lAtts(array( > 'class' => '', > 'escape' => 'html', > 'wraptag' => '', > ), $atts)); > > if ($thisimage['caption']) > { > $caption = ($escape == 'html') ? > htmlspecialchars($thisimage['caption']) : $thisimage['caption']; > > return ($wraptag) ? doTag($caption, $wraptag, $class) : $caption; > } > } > > //-------------------------------------------------------------------------- > > function image_author() > { > global $thisimage; > assert_image(); > return $thisimage['author']; > } > > //-------------------------------------------------------------------------- > > function image_date($atts) > { > global $thisimage; > assert_image(); > > extract(lAtts(array( > 'format' => '', > ), $atts)); > > if ($thisimage['date']) { > return fileDownloadFormatTime(array( > 'ftime' => $thisimage['date'], > 'format' => $format > )); > } > } > > //-------------------------------------------------------------------------- > > function image_link($atts, $thing) > { > global $thisimage, $permlink_mode, $img_dir; > > extract(lAtts(array( > 'name' => '', > 'id' => '', > ), $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 = image_url(array()); > $out = ($thing) ? href(parse($thing), $url) : $url; > > // cleanup: this wasn't called from a form, > // so we don't want this value remaining > if (!$from_form) > { > $thisimage = ''; > } > > return $out; > } > } > > //-------------------------------------------------------------------------- > > function if_thumbnail($atts, $thing) > { > global $thisimage; > assert_image(); > > return parse(EvalElse($thing, ($thisimage['thumbnail'] == 1))); > } > > > // -------------------------------------------------------------