本文整理汇总了PHP中SimpleUrl类的典型用法代码示例。如果您正苦于以下问题:PHP SimpleUrl类的具体用法?PHP SimpleUrl怎么用?PHP SimpleUrl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleUrl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _createAction
function _createAction($action, $base)
{
if (is_bool($action)) {
return $base;
}
$url = new SimpleUrl($action);
return $url->makeAbsolute($base);
}
示例2: testDefaultFrameTargetOnForm
function testDefaultFrameTargetOnForm()
{
$tag = new SimpleFormTag(array('method' => 'GET', 'action' => 'here.php', 'id' => '33'));
$form = new SimpleForm($tag, new SimpleUrl('http://host/a/index.html'));
$form->setDefaultTarget('frame');
$expected = new SimpleUrl('http://host/a/here.php');
$expected->setTarget('frame');
$this->assertEqual($form->getAction(), $expected);
}
示例3: testEncodedParameters
function testEncodedParameters()
{
$url = new SimpleUrl("");
$url->addRequestParameter("a", '?!"\'#~@[]{}:;<>,./|£$%^&*()_+-=');
$this->assertIdentical($request = $url->getEncodedRequest(), "?a=%3F%21%22%27%23%7E%40%5B%5D%7B%7D%3A%3B%3C%3E%2C.%2F%7C%A3%24%25%5E%26%2A%28%29_%2B-%3D");
$url = new SimpleUrl("?a=%3F%21%22%27%23%7E%40%5B%5D%7B%7D%3A%3B%3C%3E%2C.%2F%7C%A3%24%25%5E%26%2A%28%29_%2B-%3D");
$request = $url->getRequest();
$this->assertEqual($request["a"], '?!"\'#~@[]{}:;<>,./|£$%^&*()_+-=');
}
示例4: testGetRequestWithoutIncidentGivesNoErrors
function testGetRequestWithoutIncidentGivesNoErrors()
{
$url = new SimpleUrl('http://test:secret@this.com/page.html');
$url->addRequestParameters(array('a' => 'A', 'b' => 'B'));
$agent =& new MockRequestUserAgent();
$agent->setReturnReference('_createHttpRequest', $this->_request);
$agent->SimpleUserAgent();
$response =& $agent->fetchResponse(new SimpleUrl('http://test:secret@this.com/page.html'), new SimpleGetEncoding(array('a' => 'A', 'b' => 'B')));
$this->assertFalse($response->isError());
}
示例5: testDefaultFrameTargetOnForm
function testDefaultFrameTargetOnForm()
{
$page =& new MockSimplePage();
$page->expectOnce('expandUrl', array(new SimpleUrl('here.php')));
$page->setReturnValue('expandUrl', new SimpleUrl('http://host/here.php'));
$tag =& new SimpleFormTag(array('method' => 'GET', 'action' => 'here.php'));
$form =& new SimpleForm($tag, $page);
$form->setDefaultTarget('frame');
$expected = new SimpleUrl('http://host/here.php');
$expected->setTarget('frame');
$this->assertEqual($form->getAction(), $expected);
}
示例6: _createAction
/**
* Combined action attribute with current location
* to get an absolute form target.
* @param string $action Action attribute from form tag.
* @param SimpleUrl $base Page location.
* @return SimpleUrl Absolute form target.
*/
function _createAction($action, $base)
{
if ($action === false) {
return $base;
}
if ($action === true) {
$url = new SimpleUrl('');
} else {
$url = new SimpleUrl($action);
}
return $url->makeAbsolute($base);
}
示例7: _truncateHost
function _truncateHost($host)
{
$tlds = SimpleUrl::getAllTopLevelDomains();
if (preg_match('/[a-z\\-]+\\.(' . $tlds . ')$/i', $host, $matches)) {
return $matches[0];
} elseif (preg_match('/[a-z\\-]+\\.[a-z\\-]+\\.[a-z\\-]+$/i', $host, $matches)) {
return $matches[0];
}
return false;
}
示例8: _makeAbsolute
/**
* Expands expandomatic URLs into fully qualified
* URLs.
* @param SimpleUrl $url Relative URL.
* @return SimpleUrl Absolute URL.
* @access protected
*/
function _makeAbsolute($url)
{
if (!is_object($url)) {
$url = new SimpleUrl($url);
}
return $url->makeAbsolute($this->getUrl());
}
示例9: createAbsoluteUrl
/**
* Turns an incoming URL string into a
* URL object, filling the relative URL if
* a base URL is present.
* @param string $base_url Browser current URL.
* @param string $raw_url Incoming URL.
* @param hash $parameters Additional request, parameters.
* @return SimpleUrl Absolute URL.
* @access public
* @static
*/
function createAbsoluteUrl($base_url, $raw_url, $parameters = false)
{
$url = new SimpleUrl($raw_url);
if ($parameters) {
$url->addRequestParameters($parameters);
}
$url->makeAbsolute($base_url);
return $url;
}
示例10:
/**
* Fetches a page or a single frame if that is the current
* focus.
* @param SimpleUrl $url Target to fetch.
* @param SimpleEncoding $parameters GET/POST parameters.
* @return string Raw content of page.
* @access private
*/
function _load($url, $parameters)
{
$frame = $url->getTarget();
if (!$frame || !$this->_page->hasFrames() || strtolower($frame) == '_top') {
return $this->_loadPage($url, $parameters);
}
return $this->_loadFrame(array($frame), $url, $parameters);
}
示例11: expandUrl
/**
* Expands expandomatic URLs into fully qualified
* URLs.
* @param SimpleUrl $url Relative URL.
* @return SimpleUrl Absolute URL.
* @access public
*/
function expandUrl($url)
{
if (!is_object($url)) {
$url = new SimpleUrl($url);
}
$location = $this->getBaseUrl() ? $this->getBaseUrl() : new SimpleUrl();
return $url->makeAbsolute($location->makeAbsolute($this->getUrl()));
}
示例12: testReadFrameTaggedUrlsFromFrameInFocus
function testReadFrameTaggedUrlsFromFrameInFocus()
{
$frame =& new MockSimplePage();
$by_label = new SimpleUrl('l');
$by_label->setTarget('L');
$frame->setReturnValue('getUrlsByLabel', array($by_label));
$by_id = new SimpleUrl('i');
$by_id->setTarget('I');
$frame->setReturnValue('getUrlById', $by_id);
$frameset =& new SimpleFrameset(new MockSimplePage());
$frameset->addFrame($frame, 'A');
$frameset->setFrameFocus('A');
$this->assertIdentical($frameset->getUrlsByLabel('label'), array($by_label));
$this->assertIdentical($frameset->getUrlById(99), $by_id);
}
示例13: assertUrl
function assertUrl($raw, $parts, $params = false)
{
if (!is_array($params)) {
$params = array();
}
$url = new SimpleUrl($raw);
$this->assertIdentical($url->getScheme(), $parts[0], "[{$raw}] scheme->%s");
$this->assertIdentical($url->getUsername(), $parts[1], "[{$raw}] username->%s");
$this->assertIdentical($url->getPassword(), $parts[2], "[{$raw}] password->%s");
$this->assertIdentical($url->getHost(), $parts[3], "[{$raw}] host->%s");
$this->assertIdentical($url->getPort(), $parts[4], "[{$raw}] port->%s");
$this->assertIdentical($url->getPath(), $parts[5], "[{$raw}] path->%s");
$this->assertIdentical($url->getTld(), $parts[6], "[{$raw}] tld->%s");
$this->assertIdentical($url->getEncodedRequest(), $parts[7], "[{$raw}] encoded->%s");
$query = new SimpleQueryString();
foreach ($params as $key => $value) {
$query->add($key, $value);
}
$this->assertIdentical($url->getRequest(), $query, "[{$raw}] request->%s");
$this->assertIdentical($url->getFragment(), $parts[8], "[{$raw}] fragment->%s");
}
示例14: openFile
/**
* Actually opens the low level socket.
* @param SimpleUrl $file SimpleUrl file target.
* @param string $error Recipient of error message.
* @param integer $timeout Maximum time to wait for connection.
* @access protected
*/
protected function openFile($file, &$error)
{
return @fopen($file->asString(), 'r');
}
示例15: testHead
function testHead()
{
$headers =& new MockSimpleHttpHeaders($this);
$headers->setReturnValue('getMimeType', 'text/html');
$headers->setReturnValue('getResponseCode', 200);
$headers->setReturnValue('getNewCookies', array());
$response =& new MockSimpleHttpResponse($this);
$response->setReturnValue('getContent', 'stuff');
$response->setReturnReference('getHeaders', $headers);
$request =& new MockSimpleHttpRequest($this);
$request->setReturnReference('fetch', $response);
$url = new SimpleUrl('http://this.com/page.html');
$url->addRequestParameters(array('a' => 'A', 'b' => 'B'));
$agent =& new MockRequestUserAgent($this);
$agent->setReturnReference('_createHttpRequest', $request);
$agent->expectOnce('_createHttpRequest', array('HEAD', new SimpleUrl('http://test:secret@this.com/page.html?a=A&b=B'), array()));
$agent->SimpleUserAgent();
$agent->fetchResponse('HEAD', new SimpleUrl('http://test:secret@this.com/page.html'), array('a' => 'A', 'b' => 'B'));
$agent->tally();
}