LinkElement.class.php
gehe zur Dokumentation dieser Datei00001 <?php
00002
00013 class LinkElement extends AbstractElement
00014 {
00015 var $target;
00016 var $mail;
00017 var $protocol = '';
00018 var $objectId = 0;
00019 var $user = '';
00020 var $password = '';
00021 var $host = '';
00022 var $port = '';
00023 var $query = '';
00024 var $fragment = '';
00025 var $path = '';
00026
00027 var $name;
00028
00035 function setTarget( $target )
00036 {
00037 $this->target = $target;
00038
00039 $url = parse_url( $target );
00040
00041 $this->protocol = @$url['scheme'];
00042 $this->user = @$url['user' ];
00043 $this->password = @$url['pass' ];
00044 $this->host = @$url['host' ];
00045 $this->port = @$url['port' ];
00046 $this->path = @$url['path' ];
00047 $this->query = @$url['query' ];
00048 $this->fragment = @$url['fragment'];
00049
00050 if ( $this->protocol == 'object' )
00051 $this->objectId = intval($url['host']);
00052
00053
00054 if ( $this->protocol == '' )
00055 {
00056 if ( strpos($target,'@') !== false )
00057 {
00058 $this->protocol = 'mailto';
00059 $this->path = $this->target;
00060 }
00061
00062
00063 if ( intval($url['path']) > 0 )
00064 {
00065 $this->protocol = 'object';
00066 $this->objectId = intval($url['path']);
00067 }
00068 }
00069 }
00070
00071
00075 function getUrl()
00076 {
00077 $url = '';
00078
00079
00080 if ( $this->protocol != '')
00081 {
00082 $url .= $this->protocol.':';
00083
00084
00085 if ( $this->protocol != 'mailto' )
00086 $url.='//';
00087 }
00088
00089
00090
00091 if ( $this->user != '' )
00092 {
00093 $url .= $this->user;
00094 if ( $this->password != '' )
00095 {
00096 $url .= ':'.$this->password;
00097 }
00098 $url .= '@';
00099 }
00100
00101
00102 $url .= $this->host;
00103
00104
00105 if ( $this->port != '' )
00106 $url .= ':'.$this->port;
00107
00108
00109 $url .= $this->url_encode($this->path);
00110
00111
00112 if ( $this->query != '' )
00113 $url .= '?'.$this->url_encode($this->query);
00114
00115
00116
00117 if ( $this->fragment != '' )
00118 $url .= '#'.$this->url_encode($this->fragment);
00119
00120 return $url;
00121 }
00122
00123
00124
00129 function int2hex($intega)
00130 {
00131 $Ziffer = "0123456789ABCDEF";
00132 return $Ziffer[($intega%256)/16].$Ziffer[$intega%16];
00133 }
00134
00135
00136
00141 function url_encode( $text )
00142 {
00143 for($i=129;$i<255;$i++)
00144 {
00145 $in = chr($i);
00146 $out = "%C3%".$this->int2hex($i-64);
00147 $text = str_replace($in,$out,$text);
00148 }
00149 return $text;
00150 }
00151 }
00152
00153 ?>