includes/render.php
changeset 1308 f9bee9b125ee
parent 1230 31d226269d2f
child 1343 2a31905a567d
equal deleted inserted replaced
1307:5d9f6ecf748e 1308:f9bee9b125ee
  1161 			
  1161 			
  1162 			$full_tag   =& $matches[0][$i];
  1162 			$full_tag   =& $matches[0][$i];
  1163 			$filename   =& $matches[1][$i];
  1163 			$filename   =& $matches[1][$i];
  1164 			
  1164 			
  1165 			// apply recursion (hack? @todo could this be done with (?R) in PCRE?)
  1165 			// apply recursion (hack? @todo could this be done with (?R) in PCRE?)
       
  1166 			// this allows other elements such as internal/external links to be embedded in image captions
  1166 			$tag_pos = strpos($text, $full_tag);
  1167 			$tag_pos = strpos($text, $full_tag);
  1167 			$tag_end_pos = $tag_pos + strlen($full_tag);
  1168 			$tag_end_pos = $tag_pos + strlen($full_tag);
  1168 			while ( get_char_count($full_tag, ']') < get_char_count($full_tag, '[') && $tag_end_pos < strlen($text) )
  1169 			while ( get_char_count($full_tag, ']') < get_char_count($full_tag, '[') && $tag_end_pos < strlen($text) )
  1169 			{
  1170 			{
  1170 				$full_tag .= substr($text, $tag_end_pos, 1);
  1171 				$full_tag .= substr($text, $tag_end_pos, 1);
  1178 			
  1179 			
  1179 			// init the various image parameters
  1180 			// init the various image parameters
  1180 			$width = null;
  1181 			$width = null;
  1181 			$height = null;
  1182 			$height = null;
  1182 			$scale_type = null;
  1183 			$scale_type = null;
  1183 			$raw_display = false;
       
  1184 			$clear = null;
  1184 			$clear = null;
  1185 			$caption = null;
  1185 			$caption = null;
       
  1186 			$display_type = 'inline';
  1186 			
  1187 			
  1187 			// trim tag and parse particles
  1188 			// trim tag and parse particles
  1188 			$tag_trim = rtrim(ltrim($full_tag, '['), ']');
  1189 			$tag_trim = rtrim(ltrim($full_tag, '['), ']');
  1189 			// trim off the filename from the start of the tag
  1190 			// trim off the filename from the start of the tag
  1190 			$filepart_len = 1 + strlen($paths->nslist['File']) + strlen($filename) + 1;
  1191 			$filepart_len = 1 + strlen($paths->nslist['File']) + strlen($filename) + 1;
  1199 				switch($param)
  1200 				switch($param)
  1200 				{
  1201 				{
  1201 					case 'left':
  1202 					case 'left':
  1202 					case 'right':
  1203 					case 'right':
  1203 						$clear = $param;
  1204 						$clear = $param;
       
  1205 						$display_type = 'framed';
  1204 						break;
  1206 						break;
  1205 					case 'thumb':
  1207 					case 'thumb':
  1206 						$scale_type = 'thumb';
  1208 						$scale_type = 'thumb';
  1207 						break;
  1209 						break;
  1208 					case 'raw':
  1210 					case 'raw':
  1209 						$raw_display = true;
  1211 						$display_type = 'raw';
  1210 						break;
  1212 						break;
  1211 					default:
  1213 					default:
  1212 						// height specification
  1214 						// height specification
  1213 						if ( preg_match('/^([0-9]+)x([0-9]+)$/', $param, $dims) )
  1215 						if ( preg_match('/^([0-9]+)x([0-9]+)$/', $param, $dims) )
  1214 						{
  1216 						{
  1216 							$height = intval($dims[2]);
  1218 							$height = intval($dims[2]);
  1217 							break;
  1219 							break;
  1218 						}
  1220 						}
  1219 						// not the height, so see if a plugin took this over
  1221 						// not the height, so see if a plugin took this over
  1220 						// this hook requires plugins to return true if they modified anything
  1222 						// this hook requires plugins to return true if they modified anything
  1221 						$code = $plugins->setHook('img_tag_parse_params');
  1223 						$code = $plugins->setHook('img_tag_parse_params', true);
  1222 						foreach ( $code as $cmd )
  1224 						foreach ( $code as $cmd )
  1223 						{
  1225 						{
  1224 							if ( eval($cmd) )
  1226 							if ( eval($cmd) )
  1225 								break 2;
  1227 								break 2;
  1226 						}
  1228 						}
  1261 			// if ( isset($r_width) && isset($r_height) && $scale_type != '|thumb' )
  1263 			// if ( isset($r_width) && isset($r_height) && $scale_type != '|thumb' )
  1262 			// {
  1264 			// {
  1263 			//   $img_tag .= 'width="' . $r_width . '" height="' . $r_height . '" ';
  1265 			//   $img_tag .= 'width="' . $r_width . '" height="' . $r_height . '" ';
  1264 			// }
  1266 			// }
  1265 			
  1267 			
  1266 			$img_tag .= 'style="border-width: 0px; /* background-color: white; */" ';
  1268 			$img_tag .= 'style="border-width: 0px;" ';
  1267 			
  1269 			
  1268 			$code = $plugins->setHook('img_tag_parse_img');
  1270 			$code = $plugins->setHook('img_tag_parse_img');
  1269 			foreach ( $code as $cmd )
  1271 			foreach ( $code as $cmd )
  1270 			{
  1272 			{
  1271 				eval($cmd);
  1273 				eval($cmd);
  1274 			$img_tag .= '/>';
  1276 			$img_tag .= '/>';
  1275 			
  1277 			
  1276 			$s_full_tag = self::escape_parser_hint_attrib($full_tag);
  1278 			$s_full_tag = self::escape_parser_hint_attrib($full_tag);
  1277 			$complete_tag = '<!--#imagelink src="' . $s_full_tag . '" -->';
  1279 			$complete_tag = '<!--#imagelink src="' . $s_full_tag . '" -->';
  1278 			
  1280 			
  1279 			if ( !empty($scale_type) && !$raw_display )
  1281 			if ( $display_type == 'framed' )
  1280 			{
  1282 			{
  1281 				$complete_tag .= '<div class="thumbnail" ';
  1283 				$complete_tag .= '<div class="thumbnail" ';
  1282 				$clear_text = '';
  1284 				$clear_text = '';
  1283 				if ( !empty($clear) )
  1285 				if ( !empty($clear) )
  1284 				{
  1286 				{
  1300 					$complete_tag .= $mag_button . $caption;
  1302 					$complete_tag .= $mag_button . $caption;
  1301 				}
  1303 				}
  1302 				
  1304 				
  1303 				$complete_tag .= '</div>';
  1305 				$complete_tag .= '</div>';
  1304 			}
  1306 			}
  1305 			else if ( $raw_display )
  1307 			else if ( $display_type == 'raw' )
  1306 			{
  1308 			{
  1307 				$complete_tag .= "$img_tag";
  1309 				$complete_tag .= "$img_tag";
  1308 				$taglist[$i] = $complete_tag;
  1310 				$taglist[$i] = $complete_tag;
  1309 				
  1311 				
  1310 				$repl = "{$s_delim}e_img_{$i}{$f_delim}";
  1312 				$repl = "{$s_delim}e_img_{$i}{$f_delim}";