本文整理汇总了PHP中SimpleUrl类的典型用法代码示例。如果您正苦于以下问题:PHP SimpleUrl类的具体用法?PHP SimpleUrl怎么用?PHP SimpleUrl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleUrl类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _createAction
function _createAction($action, $base)
{
if (is_bool($action)) {
return $base;
}
$url = new SimpleUrl($action);
return $url->makeAbsolute($base);
}
开发者ID:BackupTheBerlios,项目名称:phpbase-svn,代码行数:8,代码来源:form.php
示例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);
}
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:9,代码来源:form_test.php
示例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"], '?!"\'#~@[]{}:;<>,./|£$%^&*()_+-=');
}
开发者ID:adamfranco,项目名称:harmoni,代码行数:9,代码来源:http_test.php
示例4: testGetRequestWithoutIncidentGivesNoErrors
function testGetRequestWithoutIncidentGivesNoErrors()
{
$url = new SimpleUrl('http://test:[email protected]/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:[email protected]/page.html'), new SimpleGetEncoding(array('a' => 'A', 'b' => 'B')));
$this->assertFalse($response->isError());
}
开发者ID:pvalencia,项目名称:CoordinaChile,代码行数:10,代码来源:user_agent_test.php
示例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);
}
开发者ID:Nikitian,项目名称:fl-ru-damp,代码行数:12,代码来源:form_test.php
示例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);
}
开发者ID:BGCX067,项目名称:ezpdo2-svn-to-git,代码行数:19,代码来源:form.php
示例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;
}
开发者ID:BackupTheBerlios,项目名称:phpbase-svn,代码行数:10,代码来源:http.php
示例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());
}
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:14,代码来源:page.php
示例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;
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:20,代码来源:user_agent.php
示例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);
}
开发者ID:ljarray,项目名称:dbpedia,代码行数:16,代码来源:browser.php
示例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()));
}
开发者ID:r-kitaev,项目名称:limb,代码行数:15,代码来源:page.php
示例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);
}
开发者ID:ready4god2513,项目名称:Journal,代码行数:15,代码来源:frames_test.php
示例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");
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:21,代码来源:http_test.php
示例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');
}
开发者ID:ngugijames,项目名称:ThinkUp,代码行数:11,代码来源:socket.php
示例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:[email protected]/page.html?a=A&b=B'), array()));
$agent->SimpleUserAgent();
$agent->fetchResponse('HEAD', new SimpleUrl('http://test:[email protected]/page.html'), array('a' => 'A', 'b' => 'B'));
$agent->tally();
}
开发者ID:justinlyon,项目名称:scc,代码行数:20,代码来源:user_agent_test.php
示例16: addHeaders
/**
* Presents the appropriate headers for this location.
* @param SimpleHttpRequest $request Request to modify.
* @param SimpleUrl $url Base of realm.
* @access public
*/
function addHeaders($request, $url)
{
if ($url->getUsername() && $url->getPassword()) {
$username = $url->getUsername();
$password = $url->getPassword();
} elseif ($realm = $this->findRealmFromUrl($url)) {
$username = $realm->getUsername();
$password = $realm->getPassword();
} else {
return;
}
$this->addBasicHeaders($request, $username, $password);
}
开发者ID:GerHobbelt,项目名称:simpletest,代码行数:19,代码来源:authentication.php
示例17: makeAbsolute
/**
* Replaces unknown sections to turn a relative
* URL into an absolute one. The base URL can
* be either a string or a SimpleUrl object.
* @param string/SimpleUrl $base Base URL.
* @access public
*/
function makeAbsolute($base)
{
if (!is_object($base)) {
$base = new SimpleUrl($base);
}
$scheme = $this->getScheme() ? $this->getScheme() : $base->getScheme();
$host = $this->getHost() ? $this->getHost() : $base->getHost();
if (substr($this->_path, 0, 1) == "/") {
$path = $this->normalisePath($this->_path);
} else {
$path = $this->normalisePath($base->getBasePath() . $this->_path);
}
$identity = '';
if ($this->_username && $this->_password) {
$identity = $this->_username . ':' . $this->_password . '@';
}
$encoded = $this->getEncodedRequest();
$fragment = $this->getFragment() ? '#' . $this->getFragment() : '';
return new SimpleUrl("{$scheme}://{$identity}{$host}{$path}{$encoded}{$fragment}");
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:27,代码来源:url.php
示例18: _linkIsAbsolute
/**
* Test to see if link is an absolute one.
* @param string $url Url to test.
* @return boolean True if absolute.
* @access protected
*/
function _linkIsAbsolute($url)
{
$parsed = new SimpleUrl($url);
return (bool) ($parsed->getScheme() && $parsed->getHost());
}
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:11,代码来源:page.php
示例19: makeAbsolute
/**
* Replaces unknown sections to turn a relative
* URL into an absolute one. The base URL can
* be either a string or a SimpleUrl object.
* @param string/SimpleUrl $base Base URL.
* @access public
*/
function makeAbsolute($base)
{
if (!is_object($base)) {
$base = new SimpleUrl($base);
}
if ($this->getHost()) {
$scheme = $this->getScheme();
$host = $this->getHost();
$port = $this->getPort() ? ':' . $this->getPort() : '';
$identity = $this->getIdentity() ? $this->getIdentity() . '@' : '';
if (!$identity) {
$identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
}
} else {
$scheme = $base->getScheme();
$host = $base->getHost();
$port = $base->getPort() ? ':' . $base->getPort() : '';
$identity = $base->getIdentity() ? $base->getIdentity() . '@' : '';
}
$path = $this->normalisePath($this->extractAbsolutePath($base));
$encoded = $this->getEncodedRequest();
$fragment = $this->getFragment() ? '#' . $this->getFragment() : '';
$coords = $this->getX() === false ? '' : '?' . $this->getX() . ',' . $this->getY();
return new SimpleUrl("{$scheme}://{$identity}{$host}{$port}{$path}{$encoded}{$fragment}{$coords}");
}
开发者ID:continuousphptest,项目名称:workflow.test,代码行数:32,代码来源:url.php
示例20: _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 === '' || $action === false) {
return $base;
}
$url = new SimpleUrl($action);
return $url->makeAbsolute($base);
}
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:15,代码来源:form.php
注:本文中的SimpleUrl类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论