#native_company# #native_desc#
#native_cta#

generic_url class

By Jason White
on July 12, 2002

Version: .9

Type: Class

Category: HTML

License: GNU General Public License

Description: This is a Generic URL class, complete with to_String() for text display, and to_HTML() for generating hyperlinks. Convenient for storing and retrieving ULRs from databases.

<?
//contrib : Jason White [email protected]
//GNU general public license
class generic_url {
      var $protocol;
      var $host;
      var $path;
      var $port;
      var $args;
      var $tag;
      var $description;
      var $protocols;
      
      function url()
      {
               //allows for adding the ability to check for types
               //$this->$protocols = array( "http", "ftp", "https", "file" );
      }
      function to_String()
      {
	  $port ="";
	  $args ="";
          if($this->port){
		$temp = $this->port;
		$port = ":";
		$port .= $temp;
          }
          if($this->args){
	      $temp = $this->args;
              $args = "?";
	      $args .= $temp;
          }
	  $temp  =$this->protocol;
	  $temp .="://";
	  $temp .=$this->host;
          $temp .=$port;
	  $temp .=$this->path;
	  $temp .=$args;

          return $temp;
      }
      function to_HTML()
      {
	$temp  = "<A href="";
	$temp .= $this->to_String();
	$temp .= "">";
	$temp .= $this->tag;
	$temp .= "</A>";
          return $temp;
      }
      function set_protocol($input)
      {
          $this->protocol = $input;
      }
      function set_host($input)
      {
          $this->host = $input;
      }
      function set_port($input)
      {
          $this->port = $input;
      }
      function set_path($input)
      {
          $this->path = $input;
      }
      function set_tag($input)
      {
          $this->tag = $input;
      }
      function set_args($input)
      {
          $this->args = $input;
      }
      function set_description($input)
      {
          $this->description = $input;
      }

}