Sha256: c3eb98e5b0cd633987bfc2b26430763d1e24c95801577c781b8c8bb9425cf708

Contents?: true

Size: 1.11 KB

Versions: 11

Compression:

Stored size: 1.11 KB

Contents

<?php

class AbcURL{

	public $URL;
	public $originalURL;

	public function __construct($URL = null){
		if (!$URL) $URL = $_SERVER['REQUEST_URI'];
		$this->URL = $URL;
		$this->originalURL = $URL;
	}

	public static function get($URL = null){
		return new self($URL);
	}

	// this is a bit brief but will work until something better is put in place
	public function q(array $data){
		$url = parse_url($this->URL);
		!empty($url['query']) ? parse_str($url['query'],$r) : $r = array() ;
		$data = array_merge($r,$data);
		$url['query'] = http_build_query($data);
		$this->URL = self::buildURL($url);
		return $this;
	}

	public static function buildURL($data){
		$url = "";
		if (!empty($data['scheme'])) 						$url.=$data['scheme']."://";
		if (!empty($data['user']) && !empty($url['pass']))	$url.=$data['user'].":".$url['pass']."@";
		if (!empty($data['host']))							$url.=$data['host'];
		if (!empty($data['path']))							$url.=$data['path'];
		if (!empty($data['query']))							$url.="?".$data['query'];
		if (!empty($data['fragment']))						$url.="#".$data['fragment'];
		return $url;
	}

}

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bonethug-0.0.17 skel/project_types/silverstripe3/public/abc/code/Classes/AbcURL.php
bonethug-0.0.16 skel/project_types/silverstripe3/public/abc/code/Classes/AbcURL.php
bonethug-0.0.15 skel/project_types/silverstripe3/public/abc/code/Classes/AbcURL.php
bonethug-0.0.14 skel/project_types/silverstripe3/public/abc/code/Classes/AbcURL.php
bonethug-0.0.13 skel/project_types/silverstripe3/public/abc/code/Classes/AbcURL.php
bonethug-0.0.12 skel/project_types/silverstripe3/public/abc/code/Classes/AbcURL.php
bonethug-0.0.11 skel/project_types/silverstripe3/public/abc/code/Classes/AbcURL.php
bonethug-0.0.10 skel/project_types/silverstripe3/public/abc/code/Classes/AbcURL.php
bonethug-0.0.7 skel/project_types/silverstripe3/public/abc/code/Classes/AbcURL.php
bonethug-0.0.6 skel/project_types/silverstripe3/public/abc/code/Classes/AbcURL.php
bonethug-0.0.5 skel/project_types/silverstripe3/public/abc/code/Classes/AbcURL.php