LinkElement.class.php

gehe zur Dokumentation dieser Datei
00001 <?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                // "..."->"123"
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           // Protokollangabe im Format <protokoll>://
00080           if   ( $this->protocol != '')
00081           {
00082                $url .= $this->protocol.':';
00083           
00084                // Ausnahme: Das "mailto"-Protokoll darf keinen Doppelslash haben.
00085                if   ( $this->protocol != 'mailto' )
00086                     $url.='//';
00087           }
00088                
00089           // Benutzer und Kennwort anhängen.
00090           // Format: <benutzer>:<kennwort>@
00091           if   ( $this->user != '' )
00092           {
00093                $url .= $this->user;
00094                if   ( $this->password != '' )
00095                {
00096                     $url .= ':'.$this->password;
00097                }
00098                $url .= '@';
00099           }
00100           
00101           // Hostnamen anhängen.
00102           $url .= $this->host;
00103           
00104           // Port anhängen
00105           if   ( $this->port != '' )
00106                $url .= ':'.$this->port;
00107           
00108           // Den Pfad anhängen.
00109           $url .= $this->url_encode($this->path);
00110 
00111           // Den Query-Teil mit einem "?" getrennt anhängen.
00112           if   ( $this->query != '' )
00113                $url .= '?'.$this->url_encode($this->query);
00114 //             $url .= '?'.urlencode($this->query);
00115 
00116           // Fragment mit "#" getrennt anhängen.
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 ?>

Erzeugt am Thu May 14 00:55:49 2009 für OpenRat von  doxygen 1.5.8