本文整理汇总了PHP中URL::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP URL::generate方法的具体用法?PHP URL::generate怎么用?PHP URL::generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URL
的用法示例。
在下文中一共展示了URL::generate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: _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;
}
示例3: 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();
}
示例4: 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;
}
示例5: 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;
}
示例6: getURLs
protected function getURLs()
{
$urls = array();
$regional = new \URL('msp');
$urls['regional'] = $regional->generate();
return $urls;
}
示例7: 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;
}
示例8: getPostCodeChangeURL
private function getPostCodeChangeURL()
{
global $THEUSER;
$CHANGEURL = new \URL('userchangepc');
if ($THEUSER->isloggedin()) {
$CHANGEURL = new \URL('useredit');
}
return $CHANGEURL->generate();
}
示例9: display_front_ni
protected function display_front_ni()
{
global $this_page;
$this_page = "nioverview";
$data = array();
$urls = array();
$data['popular_searches'] = NULL;
$search = new \URL('search');
$urls['search'] = $search->generate();
$alert = new \URL('alert');
$urls['alert'] = $alert->generate();
$data['urls'] = $urls;
$DEBATELIST = new \NILIST();
$debates = $DEBATELIST->display('recent_debates', array('days' => 30, 'num' => 6), 'none');
$MOREURL = new \URL('nidebatesfront');
$MOREURL->insert(array('more' => 1));
// this makes sure that we don't repeat this debate in the list below
$random_debate = NULL;
if (isset($debates['data']) && count($debates['data'])) {
$random_debate = $debates['data'][0];
}
$recent = array();
if (isset($debates['data']) && count($debates['data'])) {
for ($i = 1; $i < 6; $i++) {
$debate = $debates['data'][$i];
$debate['desc'] = "Northern Ireland Assembly debates";
$debate['more_url'] = $MOREURL->generate();
$recent[] = $debate;
}
}
$featured = array();
if ($random_debate) {
$featured = $random_debate;
$featured['more_url'] = $MOREURL->generate();
$featured['desc'] = 'Northern Ireland Assembly debate';
$featured['related'] = array();
$featured['featured'] = false;
}
$data['featured'] = $featured;
$data['debates'] = array('recent' => $recent);
$data['regional'] = $this->getMLAList();
\MySociety\TheyWorkForYou\Renderer::output('ni/index', $data);
}
示例10: getURLs
protected function getURLs()
{
$urls = array();
$search = new \URL('search');
$urls['search'] = $search->generate();
$alert = new \URL('alert');
$urls['alert'] = $alert->generate();
$regional = new \URL('msp');
$urls['regional'] = $regional->generate();
return $urls;
}
示例11: get_values
public function get_values()
{
global $this_page;
$data = array();
// TODO: think about not hard coding these
$current_question = 3;
$always_ask = 1;
$data['survey_site'] = "twfy-mini-{$current_question}";
$show_survey_qn = 0;
$referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
$has_answered_question = get_http_var('answered_survey');
$hide_question = get_http_var('hide_survey');
$data['show'] = false;
if ($hide_question) {
$always_ask = 0;
$show_survey_qn = $current_question;
setcookie('survey', $current_question, time() + 60 * 60 * 24 * 365, '/');
} elseif ($has_answered_question == $current_question && !$always_ask) {
$show_survey_qn = $current_question;
setcookie('survey', $current_question, time() + 60 * 60 * 24 * 365, '/');
} elseif (isset($_COOKIE['survey'])) {
$show_survey_qn = $_COOKIE['survey'];
}
if ($show_survey_qn < $current_question && !$has_answered_question) {
$data['show'] = true;
$page_url = '';
$hide_url = '';
if (in_array($this_page, array('mp', 'peer', 'msp', 'mla', 'royal'))) {
global $MEMBER;
if ($MEMBER) {
$page_url = $MEMBER->url() . "?answered_survey={$current_question}";
$hide_url = $MEMBER->url() . "?hide_survey={$current_question}";
}
} else {
$URL = new \URL($this_page);
$URL->insert(array('answered_survey' => $current_question));
$page_url = 'http://' . DOMAIN . $URL->generate();
$URL = new \URL($this_page);
$URL->insert(array('hide_survey' => $current_question));
$hide_url = 'http://' . DOMAIN . $URL->generate();
}
$data['page_url'] = $page_url;
$data['hide_url'] = $hide_url;
$data['user_code'] = bin2hex(urandom_bytes(16));
$data['auth_signature'] = auth_sign_with_shared_secret($data['user_code'], OPTION_SURVEY_SECRET);
$data['datetime'] = time();
}
$data['current_q'] = $current_question;
$data['answered'] = $has_answered_question;
return $data;
}
示例12: addCommonURLs
private static function addCommonURLs($data)
{
$urls = array();
if (isset($data['urls'])) {
$urls = $data['urls'];
}
$common_urls = array('search', 'alert');
foreach ($common_urls as $path) {
if (!isset($urls[$path])) {
$url = new \URL($path);
$urls[$path] = $url->generate();
}
}
$data['urls'] = $urls;
return $data;
}
示例13: search_bullet_point
function search_bullet_point()
{
global $SEARCHURL;
?>
<li> <?php
$SEARCHURL = new URL('search');
?>
<form action="<?php
echo $SEARCHURL->generate();
?>
" method="get">
<p><strong><label for="s">Search<?php
echo get_http_var("keyword") ? ' Hansard for \'' . htmlspecialchars(get_http_var("keyword")) . '\'' : '';
?>
:</label></strong>
<input type="text" name="s" id="s" size="15" maxlength="100" class="text" value="<?php
echo htmlspecialchars(get_http_var("keyword"));
?>
"> <input type="submit" value="SEARCH" class="submit"></p>
<?php
// Display popular queries
global $SEARCHLOG;
$popular_searches = $SEARCHLOG->popular_recent(10);
if (count($popular_searches) > 0) {
?>
<p>Popular searches today: <?php
$lentotal = 0;
$correct_amount = array();
// Select a number of queries that will fit in the space
foreach ($popular_searches as $popular_search) {
$len = strlen($popular_search['visible_name']);
if ($lentotal + $len > 32) {
continue;
}
$lentotal += $len;
array_push($correct_amount, $popular_search['display']);
}
print implode(", ", $correct_amount);
?>
</p> <?php
}
?>
</form>
</li>
<?php
}
示例14: display_page
function display_page($errors = array())
{
global $this_page, $PAGE;
if (isset($errors["sending"])) {
$PAGE->error_message($errors["sending"]);
} else {
print "<p>If you can't remember your password we can send you a new one.</p>\n<p>If you would like a new password, enter your address below.</p>\n";
}
?>
<form method="get" action="<?php
$URL = new URL($this_page);
echo $URL->generate();
?>
">
<?php
if (isset($errors["email"])) {
$PAGE->error_message($errors["email"]);
}
if (isset($errors["passwordchange"])) {
$PAGE->error_message($errors["passwordchange"]);
}
?>
<div class="row">
<div class="left">Email address:</div>
<div class="right"><input type="text" name="email" value="<?php
echo _htmlentities(get_http_var("email"));
?>
" maxlength="100" size="30" class="form"></div>
</div>
<div class="row">
<div class="left"> </div>
<div class="right"><input type="submit" value="Send me a new password"></div>
</div>
<input type="hidden" name="submitted" value="true">
</form>
<?php
}
示例15: public_bill_committees
protected function public_bill_committees()
{
global $this_page, $DATA, $PAGE;
$id = get_http_var('id');
$bill_id = null;
if ($this->session && $this->bill) {
$q = $this->list->db->query('select id,standingprefix from bills where title = :bill
and session = :session', array(':bill' => $this->bill, ':session' => $this->session));
if ($q->rows()) {
$bill_id = $q->field(0, 'id');
$standingprefix = $q->field(0, 'standingprefix');
}
}
if ($bill_id && $id) {
return $this->display_section_or_speech(array('gid' => $standingprefix . $id));
} elseif ($bill_id) {
# Display the page for a particular bill
$this_page = 'pbc_bill';
$args = array('id' => $bill_id, 'title' => $this->bill, 'session' => $this->session);
$data = array();
$data['content'] = $this->list->display('bill', $args, 'none');
$data['session'] = $this->session;
$data['template'] = 'section/pbc_bill';
return $this->addCommonData($data);
} elseif ($this->session && $this->bill) {
# Illegal bill title, redirect to session page
$URL = new \URL('pbc_session');
header('Location: ' . $URL->generate() . urlencode($this->session));
exit;
} elseif ($this->session) {
# Display the bills for a particular session
$this_page = 'pbc_session';
$DATA->set_page_metadata($this_page, 'title', "Session {$this->session}");
$args = array('session' => $this->session);
$data = array();
$data['rows'] = $this->list->display('session', $args, 'none');
$data['template'] = 'section/pbc_session';
$data['session'] = $this->session;
return $this->addCommonData($data);
} else {
return $this->display_front();
}
}