本文整理汇总了PHP中URL::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP URL::insert方法的具体用法?PHP URL::insert怎么用?PHP URL::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类URL
的用法示例。
在下文中一共展示了URL::insert方法的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: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: gid_to_url
function gid_to_url($gid)
{
if (!$gid) {
return '';
}
global $hansardmajors;
global $db;
$q = $db->query("SELECT major FROM hansard WHERE gid = :gid", array(':gid' => $gid));
$url_gid = fix_gid_from_db($gid);
$url = new \URL($hansardmajors[$q->field(0, 'major')]['page']);
$url->insert(array('id' => $url_gid));
$url = 'http://' . DOMAIN . $url->generate();
return $url;
}
示例6: 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);
}
示例7: MEMBER
# Stop infinite loop
# And cope with Unicode URL
if (preg_match("#^ynys môn#i", $cconstituency)) {
$cconstituency = "ynys môn";
}
// Redirect for MP recent appearanecs
if (get_http_var('recent')) {
if ($THEUSER->constituency_is_set() && !$pid) {
$MEMBER = new MEMBER(array('constituency' => $THEUSER->constituency()));
if ($MEMBER->person_id()) {
$pid = $MEMBER->person_id();
}
}
if ($pid) {
$URL = new URL('search');
$URL->insert(array('pid' => $pid, 'pop' => 1));
header('Location: http://' . DOMAIN . $URL->generate('none'));
exit;
}
}
/////////////////////////////////////////////////////////
// CHECK SUBMITTED MEMBER (term of office) ID.
if (get_http_var('c4')) {
$this_page = 'c4_mp';
} elseif (get_http_var('c4x')) {
$this_page = 'c4x_mp';
} elseif (get_http_var('peer')) {
$this_page = 'peer';
} elseif (get_http_var('royal')) {
$this_page = 'royal';
} elseif (get_http_var('mla')) {
示例8: confirm
function confirm($token)
{
// The user has clicked the link in their confirmation email
// and the confirm page has passed the token from the URL to here.
// If all goes well they'll be confirmed and then logged in.
// Split the token into its parts.
$arg = '';
if (strstr($token, '::')) {
$arg = '::';
}
if (strstr($token, '-')) {
$arg = '-';
}
list($user_id, $registrationtoken) = explode($arg, $token);
if (!is_numeric($user_id) || $registrationtoken == '') {
return false;
}
$q = $this->db->query("SELECT email, password, postcode\n\t\t\t\t\t\tFROM\tusers\n\t\t\t\t\t\tWHERE\tuser_id = '" . mysql_escape_string($user_id) . "'\n\t\t\t\t\t\tAND\t\tregistrationtoken = '" . mysql_escape_string($registrationtoken) . "'\n\t\t\t\t\t\t");
if ($q->rows() == 1) {
// We'll need these to be set before logging the user in.
$this->user_id = $user_id;
$this->email = $q->field(0, 'email');
$this->password = $q->field(0, 'password');
// Set that they're confirmed in the DB.
$r = $this->db->query("UPDATE users\n\t\t\t\t\t\t\tSET\t\tconfirmed = '1'\n\t\t\t\t\t\t\tWHERE\tuser_id = '" . mysql_escape_string($user_id) . "'\n\t\t\t\t\t\t\t");
if ($q->field(0, 'postcode')) {
$MEMBER = new MEMBER(array('postcode' => $q->field(0, 'postcode')));
$pid = $MEMBER->person_id();
# This should probably be in the ALERT class
$this->db->query('update alerts set confirmed=1 where email="' . mysql_escape_string($this->email) . '" and criteria="speaker:' . mysql_escape_string($pid) . '"');
}
if ($r->success()) {
$this->confirmed = true;
// Log the user in, redirecting them to the confirm page
// where they should get a nice welcome message.
$URL = new URL('userconfirmed');
$URL->insert(array('welcome' => 't'));
$redirecturl = $URL->generate();
$this->login($redirecturl, 'session');
} else {
// Couldn't set them as confirmed in the DB.
return false;
}
} else {
// Couldn't find this user in the DB. Maybe the token was
// wrong or incomplete?
return false;
}
}
示例9: URL
'first_name' => 'Fred',
'last_name' => 'Bloggs,
'person_id' => 23,
'constituency' => 'Here',
'party' => 'Them'
)
);
*/
global $this_page;
twfy_debug("TEMPLATE", "people_mps.php");
$order = $data['info']['order'];
$URL = new URL($this_page);
if ($order == 'first_name') {
$th_first_name = 'First Name |';
} else {
$URL->insert(array('o' => 'f'));
$th_first_name = '<a href="' . $URL->generate() . '">First name</a> |';
}
if ($order == 'last_name') {
$th_last_name = 'Last name |';
} else {
$URL->insert(array('o' => 'l'));
$th_last_name = '<a href="' . $URL->generate() . '">Last name</a> |';
}
$URL->insert(array('o' => 'p'));
$th_party = '<a href="' . $URL->generate() . '">Party</a>';
$URL->insert(array('o' => 'c'));
$th_constituency = '<a href="' . $URL->generate() . '">Constituency</a>';
if ($order == 'party') {
$th_party = 'Party';
} elseif ($order == 'constituency') {
示例10: addslashes
function _set_url()
{
global $hansardmajors;
// Creates and sets the URL for the comment.
if ($this->url == '') {
$q = $this->db->query("SELECT major,\n\t\t\t\t\t\t\t\t\tgid\n\t\t\t\t\t\t\tFROM\thansard\n\t\t\t\t\t\t\tWHERE\tepobject_id = '" . addslashes($this->epobject_id) . "'\n\t\t\t\t\t\t\t");
if ($q->rows() > 0) {
// If you change stuff here, you might have to change it in
// $COMMENTLIST->_get_comment_data() too...
$gid = fix_gid_from_db($q->field(0, 'gid'));
// In includes/utility.php
$major = $q->field(0, 'major');
$page = $hansardmajors[$major]['page'];
$gidvar = $hansardmajors[$major]['gidvar'];
$URL = new URL($page);
$URL->insert(array($gidvar => $gid));
$this->url = $URL->generate() . '#c' . $this->comment_id;
}
}
}
示例11: COUNT
// Get the total comments posted for this user.
$r = $db->query("SELECT COUNT(*) AS totalcount\n FROM\tcomments\n WHERE\tuser_id = '" . $user_id . "'");
$totalcomments = $r->field(0, 'totalcount');
$percentagedeleted = $q->field($row, 'deletedcount') / $totalcomments * 100;
// Get complaints made about this user's comments, but not upheld.
$r = $db->query("SELECT COUNT(*) AS count\n FROM commentreports, comments\n WHERE\tcommentreports.comment_id = comments.comment_id\n AND\t\tcomments.user_id = '{$user_id}'\n AND\t\tcommentreports.resolved IS NOT NULL\n AND\t\tcommentreports.upheld = '0'");
$notupheldcount = $r->field(0, 'count');
$USERURL->insert(array('u' => $user_id));
$rows[] = array('<a href="' . $USERURL->generate() . '">' . $q->field($row, 'firstname') . ' ' . $q->field($row, 'lastname') . '</a>', $totalcomments, $q->field($row, 'deletedcount'), $percentagedeleted . '%', $notupheldcount);
}
$tabledata = array('header' => array('Name', 'Total comments', 'Number deleted', 'Percentage deleted', 'Reports against not upheld'), 'rows' => $rows);
$PAGE->display_table($tabledata);
///////////////////////////////////////////////////////////////
?>
<h4>Users who've made most rejected reports</h4>
<?php
$q = $db->query("SELECT COUNT(*) AS rejectedcount,\n cr.user_id,\n u.firstname,\n u.lastname\n FROM\tcommentreports cr, users u\n WHERE\tcr.resolved IS NOT NULL\n AND\t\tcr.upheld = '0'\n AND\t\tcr.user_id = u.user_id\n AND\t\tcr.user_id != 0\n GROUP BY cr.user_id\n ORDER BY rejectedcount DESC");
$rows = array();
$USERURL = new URL('userview');
for ($row = 0; $row < $q->rows(); $row++) {
$user_id = $q->field($row, 'user_id');
$USERURL->insert(array('u' => $user_id));
// Get how many valid complaints they've submitted.
$r = $db->query("SELECT COUNT(*) AS upheldcount\n FROM commentreports\n WHERE\tuser_id = '{$user_id}'\n AND\t\tupheld = '1'");
$rows[] = array('<a href="' . $USERURL->generate() . '">' . $q->field($row, 'firstname') . ' ' . $q->field($row, 'lastname') . '</a>', $q->field($row, 'rejectedcount'), $r->field(0, 'upheldcount'));
}
$tabledata = array('header' => array('Name', 'Reports not upheld', 'Reports upheld'), 'rows' => $rows);
$PAGE->display_table($tabledata);
$menu = $PAGE->admin_menu();
$PAGE->stripe_end(array(array('type' => 'html', 'content' => $menu)));
$PAGE->page_end();
示例12: max
$db = $HANSARDLIST->db;
// Get all the person ids we need feeds for...
$q = $db->query("SELECT person_id, group_concat(member_id order by member_id separator ',') as member_ids\n\t\t\tFROM member GROUP BY person_id HAVING max(left_house)='9999-12-31'");
if ($q->rows() <= 0) {
exit;
}
$starttime = time();
for ($personrow = 0; $personrow < $q->rows(); $personrow++) {
$person_id = $q->field($personrow, 'person_id');
$member_ids = $q->field($personrow, 'member_ids');
$args = array('member_ids' => $member_ids);
$speeches = $HANSARDLIST->display('person', $args, 'none');
// Some data about this person that we'll need for the feed.
$MEMBER = new MEMBER(array('person_id' => $person_id));
$MPURL = new URL('mp');
$MPURL->insert(array('pid' => $person_id));
$mpurl = $MPURL->generate();
$date = gmdate('Y-m-d');
$time = gmdate('H:i:s');
$datenow = $date . 'T' . $time . '+00:00';
// Prepare the meat of the RSS file.
$items = '';
$entries = '';
if (isset($speeches['rows']) && count($speeches['rows']) > 0) {
foreach ($speeches['rows'] as $n => $row) {
// While we're linking to individual speeches,
// the text is the body of the parent, ie (sub)section.
$title = htmlentities(str_replace('—', '-', $row['parent']['body']));
$link = isset($row['listurl']) ? $row['listurl'] : '';
$link = 'http://' . DOMAIN . $link;
$description = htmlentities(trim_characters($row['body'], 0, 200));
示例13: display
public function display()
{
// Print all our pending items out in a nice list or something
// Add links later for "approve, decline, refer"
// Just get the fucker working for now
$URL = new URL('admin_glossary_pending');
$URL->reset();
$form_link = $URL->generate('url');
?>
<form action="<?php
echo $form_link;
?>
" method="post"><?php
foreach ($this->pending as $editqueue_id => $pender) {
$URL = new URL('admin_glossary_pending');
$URL->insert(array('approve' => $editqueue_id));
$approve_link = $URL->generate('url');
$URL = new URL('admin_glossary_pending');
$URL->insert(array('modify' => $editqueue_id));
$modify_link = $URL->generate('url');
$URL = new URL('admin_glossary_pending');
$URL->insert(array('decline' => $editqueue_id));
$decline_link = $URL->generate('url');
?>
<div class="pending-item"><label for="<?php
echo $editqueue_id;
?>
"><input type="checkbox" name="approve[]" value="<?php
echo $editqueue_id;
?>
" id="<?php
echo $editqueue_id;
?>
"><strong><?php
echo $pender['title'];
?>
</strong></label>
<p><?php
echo $pender['body'];
?>
<br>
<small>
<a href="<?php
echo $approve_link;
?>
">approve</a>
|
<a href="<?php
echo $modify_link;
?>
">modify</a>
|
<a href="<?php
echo $decline_link;
?>
">decline</a>
<br>Submitted by: <em><?php
echo $pender['firstname'];
?>
<?php
echo $pender['lastname'];
?>
</em>
</small></p></div>
<?php
}
?>
<input type="submit" value="Approve checked items">
</form><?php
}
示例14: URL
// COMMENT REPORTING LINK.
if ($this_page != 'commentreport' && $this_page != 'addcomment' && $this_page != 'admin_commentreport' && $THEUSER->is_able_to('reportcomment') && $THEUSER->user_id() != $comment['user_id'] && !$comment['modflagged']) {
// The comment hasn't been reported and we're on a page where we want to
// display this link.
$URL = new URL('commentreport');
$URL->insert(array('id' => $comment['comment_id'], 'ret' => $comment['url']));
$reporthtml = '(<a href="' . $URL->generate() . '" title="Notify moderators that this comment should be deleted">Report this comment</a>)';
} elseif ($comment['modflagged']) {
$reporthtml = '(This comment has been reported to moderators)';
} else {
// When previewing a comment...
$reporthtml = '';
}
// USERNAME AND DATE AND TIME.
$USERURL = new URL('userview');
$USERURL->insert(array('u' => $comment['user_id']));
list($date, $time) = explode(' ', $comment['posted']);
$date = format_date($date, SHORTDATEFORMAT);
$time = format_time($time, TIMEFORMAT);
?>
<p class="credit"><a href="<?php
echo $USERURL->generate();
?>
" title="See information about this user"><strong><?php
echo htmlentities($comment['firstname']) . ' ' . htmlentities($comment['lastname']);
?>
</strong></a><br>
<small>Posted on <?php
echo $date;
if (isset($comment['url'])) {
print ' <a href="' . $comment['url'] . '" title="Link to this comment">' . $time . '</a>';
示例15: array
$up_link = $URL->generate();
$URL->insert(array("gl" => $GLOSSARY->previous_term['glossary_id']));
$previous_link = $URL->generate('url');
$URL->update(array("gl" => $GLOSSARY->next_term['glossary_id']));
$next_link = $URL->generate('url');
$nextprev = array('next' => array('url' => $next_link, 'title' => 'Next term', 'body' => $GLOSSARY->next_term['title']), 'prev' => array('url' => $previous_link, 'title' => 'Previous term', 'body' => $GLOSSARY->previous_term['title']));
$DATA->set_page_metadata($this_page, 'nextprev', $nextprev);
$PAGE->glossary_display_term($GLOSSARY);
} else {
// Display the results
if (isset($GLOSSARY->terms)) {
?>
<ul class="glossary"><?php
$URL = new URL('glossary');
foreach ($GLOSSARY->alphabet[$GLOSSARY->current_letter] as $glossary_id) {
$URL->insert(array('gl' => $glossary_id));
$term_link = $URL->generate('url');
?>
<li><a href="<?php
echo $term_link;
?>
"><?php
echo $GLOSSARY->terms[$glossary_id]['title'];
?>
</a></li><?php
}
?>
</ul><?php
}
}
$URL = new URL('glossary_addterm');