本文整理汇总了PHP中URL类的典型用法代码示例。如果您正苦于以下问题:PHP URL类的具体用法?PHP URL怎么用?PHP URL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了URL类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display_page
function display_page($errors = array())
{
global $PAGE, $this_page, $THEUSER;
$PAGE->page_start();
$PAGE->stripe_start();
if ($THEUSER->isloggedin()) {
// Shouldn't really get here, but you never know.
$URL = new URL('userlogout');
?>
<p><strong>You are already logged in. <a href="<?php
echo $URL->generate();
?>
">Log out?</a></strong></p>
<?php
$PAGE->stripe_end();
$PAGE->page_end();
return;
}
?>
<p>Not yet a member? <a href="<?php
$URL = new URL("userjoin");
echo $URL->generate();
?>
">Join now</a>!</p>
<?php
$PAGE->login_form($errors);
$PAGE->stripe_end(array(array('type' => 'include', 'content' => 'userlogin')));
$PAGE->page_end();
}
示例2: get_menu_links
/**
* Get Menu Links
*
* Takes an array of pages and returns an array suitable for use in links.
*/
private function get_menu_links($pages)
{
global $DATA, $this_page;
$links = array();
foreach ($pages as $page) {
//get meta data
$menu = $DATA->page_metadata($page, 'menu');
if ($menu) {
$title = $menu['text'];
} else {
$title = $DATA->page_metadata($page, 'title');
}
$url = $DATA->page_metadata($page, 'url');
$tooltip = $DATA->page_metadata($page, 'heading');
//check for external vs internal menu links
if (!valid_url($url)) {
$URL = new \URL($page);
$url = $URL->generate();
}
//make the link
if ($page == $this_page) {
$links[] = array('href' => '#', 'title' => '', 'classes' => '', 'text' => $title);
} else {
$links[] = array('href' => $url, 'title' => $tooltip, 'classes' => '', 'text' => $title);
}
}
return $links;
}
示例3: _api_getPerson_row
function _api_getPerson_row($row, $has_party = FALSE)
{
global $parties;
$row['full_name'] = member_full_name($row['house'], $row['title'], $row['first_name'], $row['last_name'], $row['constituency']);
if ($row['house'] == 1) {
$URL = new URL('mp');
$row['url'] = $URL->generate('none') . make_member_url($row['full_name'], $row['constituency'], $row['house']);
}
if ($has_party && isset($parties[$row['party']])) {
$row['party'] = $parties[$row['party']];
}
list($image, $sz) = find_rep_image($row['person_id']);
if ($image) {
list($width, $height) = getimagesize(str_replace(IMAGEPATH, BASEDIR . '/images/', $image));
$row['image'] = $image;
$row['image_height'] = $height;
$row['image_width'] = $width;
}
if ($row['house'] == 1 && ($row['left_house'] == '9999-12-31' || $row['left_house'] == '2010-04-12')) {
# XXX
# Ministerialships and Select Committees
$db = new ParlDB();
$q = $db->query('SELECT * FROM moffice WHERE to_date="9999-12-31" and person=' . $row['person_id'] . ' ORDER BY from_date DESC');
for ($i = 0; $i < $q->rows(); $i++) {
$row['office'][] = $q->row($i);
}
}
foreach ($row as $k => $r) {
if (is_string($r)) {
$row[$k] = html_entity_decode($r);
}
}
return $row;
}
示例4: connect
/**
* Connect to store using a DSN
*
* @param string dsn
* @return bool success
* @see php://imap_open
* @throws lang.IllegalArgumentException in case scheme is not recognized
* @throws peer.mail.MessagingException
*/
public function connect($dsn)
{
$flags = OP_HALFOPEN;
// Parse DSN
$u = new URL($dsn);
$attr = $u->getParams();
// DSN supported?
if (FALSE === $this->_supports($u, $attr)) {
return FALSE;
}
// Read-only?
if ($u->getParam('open')) {
$flags ^= OP_HALFOPEN;
}
if ($u->getParam('read-only')) {
$flags |= OP_READONLY;
}
$mbx = isset($attr['mbx']) ? $attr['mbx'] : sprintf('{%s:%d/%s}', $u->getHost(), $u->getPort($attr['port']), $u->getParam('proto', $attr['proto']));
// Connect
if (FALSE === ($conn = $this->_connect($mbx, @$u->getUser(), @$u->getPassword(), $flags))) {
throw new MessagingException('Connect to "' . $u->getUser() . '@' . $mbx . '" failed', $this->_errors());
}
$this->_hdl = array($conn, $mbx);
return TRUE;
}
示例5: getURLs
protected function getURLs()
{
$urls = array();
$regional = new \URL('msp');
$urls['regional'] = $regional->generate();
return $urls;
}
示例6: get_listurl
function get_listurl($q) {
global $hansardmajors;
$id_data = array(
'gid' => fix_gid_from_db($q->field(0, 'gid')),
'major' => $q->field(0, 'major'),
'htype' => $q->field(0, 'htype'),
'subsection_id' => $q->field(0, 'subsection_id'),
);
$db = new ParlDB;
$LISTURL = new URL($hansardmajors[$id_data['major']]['page_all']);
$fragment = '';
if ($id_data['htype'] == '11' || $id_data['htype'] == '10') {
$LISTURL->insert( array( 'id' => $id_data['gid'] ) );
} else {
$parent_epobject_id = $id_data['subsection_id'];
$parent_gid = '';
$r = $db->query("SELECT gid
FROM hansard
WHERE epobject_id = '" . mysql_real_escape_string($parent_epobject_id) . "'
");
if ($r->rows() > 0) {
$parent_gid = fix_gid_from_db( $r->field(0, 'gid') );
}
if ($parent_gid != '') {
$LISTURL->insert( array( 'id' => $parent_gid ) );
$fragment = '#g' . gid_to_anchor($id_data['gid']);
}
}
return $LISTURL->generate('none') . $fragment;
}
示例7: __construct
/**
* @param APPLICATION $context
*/
public function __construct($context)
{
parent::__construct($context);
$cmd = $this->make_command();
$cmd->id = 'create';
$cmd->caption = 'New user';
$cmd->link = "create_user.php";
$cmd->icon = '{icons}buttons/create';
$cmd->executable = $this->login->is_allowed(Privilege_set_user, Privilege_create);
$cmd->importance = Command_importance_high + Command_importance_increment;
$this->append($cmd);
$link_url = new URL($this->env->url(Url_part_no_host_path));
$link_url->replace_argument('show_anon', '');
$cmd = $this->make_command();
$cmd->id = 'show_registered';
$cmd->caption = 'Show registered users';
$cmd->link = $link_url->as_text();
$cmd->icon = '{icons}buttons/login';
$cmd->executable = read_var('show_anon');
$cmd->importance = Command_importance_high;
$this->append($cmd);
$link_url->replace_argument('show_anon', 1);
$cmd = $this->make_command();
$cmd->id = 'show_anonymous';
$cmd->caption = 'Show anonymous users';
$cmd->link = $link_url->as_text();
$cmd->icon = '{icons}buttons/anonymous';
$cmd->executable = !read_var('show_anon');
$cmd->importance = Command_importance_high;
$this->append($cmd);
}
示例8: generate_rows
function generate_rows($q)
{
global $db;
$rows = array();
$USERURL = new URL('userview');
for ($row = 0; $row < $q->rows(); $row++) {
$email = $q->field($row, 'email');
$criteria = $q->field($row, 'criteria');
$SEARCHENGINE = new SEARCHENGINE($criteria);
$r = $db->query("SELECT user_id,firstname,lastname FROM users WHERE email = '" . mysql_escape_string($email) . "'");
if ($r->rows() > 0) {
$user_id = $r->field(0, 'user_id');
$USERURL->insert(array('u' => $user_id));
$name = '<a href="' . $USERURL->generate() . '">' . $r->field(0, 'firstname') . ' ' . $r->field(0, 'lastname') . '</a>';
} else {
$name = $email;
}
$created = $q->field($row, 'created');
if ($created == '0000-00-00 00:00:00') {
$created = ' ';
}
$rows[] = array($name, $SEARCHENGINE->query_description_long(), $created);
}
return $rows;
}
示例9: generate_votes
protected function generate_votes($votes, $id, $gid)
{
/*
Returns HTML for the 'Does this answer the question?' links (wrans) in the sidebar.
$votes = => array (
'user' => array ( 'yes' => '21', 'no' => '3' ),
'anon' => array ( 'yes' => '132', 'no' => '30' )
)
*/
global $this_page;
# If there's a "q" we assume it's a question and ignore it
if (strstr($gid, 'q')) {
return;
}
$data = array();
if ($this->votelinks_so_far > 0 || strstr($gid, 'r')) {
$yesvotes = $votes['user']['yes'] + $votes['anon']['yes'];
$novotes = $votes['user']['no'] + $votes['anon']['no'];
$yesplural = $yesvotes == 1 ? 'person thinks' : 'people think';
$noplural = $novotes == 1 ? 'person thinks' : 'people think';
$URL = new \URL($this_page);
$returl = $URL->generate();
$VOTEURL = new \URL('epvote');
$VOTEURL->insert(array('v' => '1', 'id' => $id, 'ret' => $returl));
$yes_vote_url = $VOTEURL->generate();
$VOTEURL->insert(array('v' => '0'));
$no_vote_url = $VOTEURL->generate();
$data = array('yesvotes' => $yesvotes, 'yesplural' => $yesplural, 'yesvoteurl' => $yes_vote_url, 'novoteurl' => $no_vote_url, 'novotes' => $novotes, 'noplural' => $noplural);
}
$this->votelinks_so_far++;
return $data;
}
示例10: FileReader
function FileReader($file = NULL)
{
$fileobj = NULL;
if (!isset($file)) {
return;
}
if (URL::validClass($file)) {
$fileobj = $file;
$path = $fileobj->toString();
} else {
if (File::validClass($file)) {
$fileobj = $file;
$path = $fileobj->getFilePath();
} else {
$str = StringBuffer::toStringBuffer($file);
if ($str->startsWith('http://') || $str->startsWith('ftp://') || $str->startsWith('php://')) {
$fileobj = new URL($str);
$path = $fileobj->toString();
} else {
$fileobj = new File($file);
$path = $fileobj->getFilePath();
}
}
}
if (isset($fileobj)) {
$this->handle = @fopen($path, 'r');
if (isset($this->handle)) {
$this->file = $fileobj;
}
}
}
示例11: done
function done($locator)
{
$response = $locator->get('Response');
$url = new URL('action');
$response->setRedirect($url->getURL('foo'));
# echo 'Form1View: DoneHandler: STATE DONE<br/>';
}
示例12: getFrobURL
/**
* Get FROB URL
*
* @param &com.flickr.xmlrpc.Client client
* @return string url
*/
public function getFrobURL($client)
{
$arguments = array('frob' => $this->getFrobValue(), 'perms' => 'read');
$arguments = $client->signArray($arguments);
$url = new URL('http://flickr.com/services/auth');
$url->addParams($arguments);
return $url->getURL();
}
示例13: isExcluded
/**
* Check whether a given URL is excluded
*
* @param peer.URL url
* @return bool
*/
public function isExcluded(URL $url)
{
foreach ($this->excludes as $pattern) {
if (stristr($url->getHost(), $pattern)) {
return TRUE;
}
}
return FALSE;
}
示例14: rewrite
static function rewrite(Location $l) {
$rv = Location::rewrite($l);
$u = new URL($rv);
$action = $u->query['action'];
unSet($u->query['action']);
$u->resource = $action;
return str_replace('?', '/', $u->toString());
}
示例15: getPostCodeChangeURL
private function getPostCodeChangeURL()
{
global $THEUSER;
$CHANGEURL = new \URL('userchangepc');
if ($THEUSER->isloggedin()) {
$CHANGEURL = new \URL('useredit');
}
return $CHANGEURL->generate();
}