Difference between revisions of "hkit-issues"

From Microformats Wiki
Jump to navigation Jump to search
(create page, add 2 new issues.)
 
(No difference)

Latest revision as of 00:39, 27 July 2009

hKit Issues

  • hCard profile import is erratic
  • If your hCard contains multiple emails or phone numbers, it will drop all of them from the output (e.g. you will have no emails/phone numbers in your output)
  • The scheme-detection in $hKit::resolvePath() cause non-http URIs to be resolved as absolute paths. That can be fixed by replacing that method with this:
		private function resolvePath($filepath)
		{	// ugly code ahoy: needs a serious tidy up
					
			$filepath	= $filepath[0];
			
			$bits = parse_url( $filepath );
			if ( !empty( $bits['scheme'] ) ) {
				return $filepath;
			}
			
			$base 	= $this->base;
			$url	= $this->url;
			
			$bits = parse_url( $base );
			if ( !empty( $bits['scheme'] ) )
				$url = $base;
			
			$r		= parse_url($url);
			$domain	= $r['scheme'] . '://' . $r['host'];

			if (!isset($r['path'])) $r['path'] = '/';
			$path	= explode('/', $r['path']);
			$file	= explode('/', $filepath);
			$new	= array('');

			if ($file[0] == ''){
				// absolute path
				return ''.$domain . implode('/', $file);
			}else{
				// relative path
				if ($path[sizeof($path)-1] == '') array_pop($path);
				if (strpos($path[sizeof($path)-1], '.') !== false) array_pop($path);

				foreach ($file as $segment){
					if ($segment == '..'){
						array_pop($path);
					}else{
						$new[]	= $segment;
					}
				}
				return ''.$domain . implode('/', $path) . implode('/', $new);
			}	
		}