本文整理汇总了PHP中url::back方法的典型用法代码示例。如果您正苦于以下问题:PHP url::back方法的具体用法?PHP url::back怎么用?PHP url::back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类url
的用法示例。
在下文中一共展示了url::back方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: width
/**
* Set page width
*
* @param string $width
*/
public function width($width)
{
$this->session->set('page_width', $width == 'wide' ? 'liquid' : 'fixed');
if (request::is_ajax()) {
return;
}
url::back();
}
示例2: __construct
/**
* Page constructor to enable role check
*/
public function __construct()
{
parent::__construct();
// Allow only admin access
if (!$this->visitor->logged_in('admin')) {
url::back();
}
$this->breadcrumb[] = html::anchor('roles', __('Roles'));
}
示例3: _topic_edit
/**
* Edit topic
*
* @param mixed $topic_id
* @param mixed $area_id
*/
public function _topic_edit($topic_id, $area_id = false)
{
$this->history = false;
$errors = array();
$forum_topic = new Forum_Topic_Model((int) $topic_id);
$forum_area = $forum_topic->loaded() ? $forum_topic->forum_area : new Forum_Area_Model((int) $area_id);
if ($forum_topic->loaded()) {
// Editing topic
$editing = true;
if (!$forum_topic->has_access(Forum_Topic_Model::ACCESS_EDIT)) {
url::back('forum');
}
} else {
if ($forum_area->loaded()) {
// New topic
$editing = false;
if (!$forum_area->has_access(Forum_Area_Model::ACCESS_WRITE)) {
url::back('forum');
}
} else {
// New topic in unknown area
$errors[] = __('Area :area or topic :topic not found', array(':area' => (int) $area_id, ':topic' => (int) $topic_id));
}
}
if (empty($errors)) {
$forum_post = new Forum_Post_Model((int) $forum_topic->first_post_id);
$form_errors = array();
$form_values_topic = $forum_topic->as_array();
$form_values_post = $forum_post->as_array();
$form_topics = false;
// Bound area?
if ($forum_area->is_type(Forum_Area_Model::TYPE_BIND)) {
// Get bind config and load topics
$bind = Forum_Area_Model::binds($forum_area->bind);
if ($editing) {
// Can't edit bound topic
$form_topics = array($forum_topic->bind_id => $forum_topic->name);
} else {
// Try to load options from configured model
try {
$bind_topics = ORM::factory($bind['model'])->find_bind_topics($forum_area->bind);
$form_topics = array(0 => __('Choose..')) + $bind_topics;
} catch (Kohana_Exception $e) {
$form_topics = array();
}
}
}
// Admin actions
if ($editing && $forum_topic->has_access(Forum_Topic_Model::ACCESS_DELETE)) {
$this->page_actions[] = array('link' => url::model($forum_topic) . '/delete/?token=' . csrf::token(), 'text' => __('Delete topic'), 'class' => 'topic-delete');
}
// Check post
if ($post = $this->input->post()) {
$post['forum_area_id'] = $forum_area->id;
$topic = $post;
if (isset($bind_topics)) {
$topic['name'] = arr::get($bind_topics, (int) $topic['bind_id'], '');
}
$post_extra = $topic_extra = array('author_id' => $this->user->id, 'author_name' => $this->user->username);
if ($editing) {
$post_extra['modifies'] = (int) $forum_post->modifies + 1;
$post_extra['modified'] = date::unix2sql(time());
}
$post_extra['author_ip'] = $this->input->ip_address();
$post_extra['author_host'] = $this->input->host_name();
// validate post first and save topic if ok
if (csrf::valid() && $forum_post->validate($post, false, $post_extra) && $forum_topic->validate($topic, true, $topic_extra)) {
// post
$forum_post->forum_topic_id = $forum_topic->id;
$forum_post->save();
if (!$editing) {
// topic
$forum_topic->first_post_id = $forum_post->id;
$forum_topic->last_post_id = $forum_post->id;
$forum_topic->last_poster = $this->user->username;
$forum_topic->last_posted = date::unix2sql(time());
$forum_topic->posts = 1;
$forum_topic->save();
// area
$forum_area->last_topic_id = $forum_topic->id;
$forum_area->posts += 1;
$forum_area->topics += 1;
$forum_area->save();
// user
$this->user->posts += 1;
$this->user->save();
// News feed
newsfeeditem_forum::topic($this->user, $forum_topic);
}
// redirect back to topic
URL::redirect(url::model($forum_topic));
} else {
$form_errors = array_merge($post->errors(), is_object($topic) ? $topic->errors() : array());
}
//.........这里部分代码省略.........
示例4: _frienddelete
/**
* Remove from friendlist
*/
public function _frienddelete()
{
$this->history = false;
// for authenticated only
if ($this->user && csrf::valid()) {
// require valid user
$this->member = new User_Model($username);
if ($this->member->id) {
$this->user->delete_friend($this->member);
}
}
url::back('members');
}
示例5: _entry_delete
/**
* Delete entry
*
* @param integer|string $entry_id
*/
public function _entry_delete($entry_id)
{
$this->history = false;
$entry = new Blog_Entry_Model((int) $entry_id);
if ($this->user && $entry->id && csrf::valid($this->input->get('token'), $this->user->id) && ($entry->is_author() || $this->visitor->logged_in('admin'))) {
$entry->delete();
url::redirect('/blogs');
}
url::back('/blogs');
}
示例6: _favorite_delete
/**
* Remove from favorites
*
* @param int|string $event_id
*/
public function _favorite_delete($event_id)
{
$this->history = false;
// for authenticated only
if ($this->user && csrf::valid()) {
// require valid user
$this->event = new Event_Model((int) $event_id);
if ($this->event->id) {
$this->event->delete_favorite($this->user);
}
}
url::back('/members');
}
示例7: empty
<?php
echo form::textarea_wrap(array('name' => 'post', 'id' => $post_id, 'rows' => 20, 'cols' => 25), $post, '', true, '', $errors);
?>
</ul>
</fieldset>
<fieldset>
<?php
echo form::csrf();
?>
<?php
echo empty($post['id']) ? '' : form::hidden('id', $post['id']);
?>
<?php
echo empty($parent_id) ? '' : form::hidden('parent_id', $parent_id);
?>
<?php
echo form::submit(false, __('Save'));
?>
<?php
echo html::anchor(request::is_ajax() ? 'forum/post/' . ($post['id'] ? $post['id'] : $parent_id) : url::back('/forum', true), __('Cancel'));
?>
</fieldset>
<?php
echo form::close();
?>
<?php
echo html::script_source('$(function() { $("#' . $post_id . '").markItUp(bbCodeSettings); });');
示例8: __
}
?>
<?php
echo form::textarea_wrap(array('name' => 'post', 'id' => 'post', 'rows' => 20, 'cols' => 25), $topic, '', true, __('Post'), $errors);
?>
</ul>
</fieldset>
<fieldset>
<?php
echo form::csrf();
?>
<?php
echo empty($topic['id']) ? '' : form::hidden('id', $topic['id']);
?>
<?php
echo form::submit(false, __('Save'));
?>
<?php
echo html::anchor(url::back('/forum', true), __('Cancel'));
?>
</fieldset>
<?php
echo form::close();
?>
<?php
echo html::script_source('$(function() { $("#post").markItUp(bbCodeSettings); });');
示例9: _venue_edit
/**
* Edit venue
*
* @param integer|string $venue_id
* @param integer|string $category_id
*/
public function _venue_edit($venue_id = false, $category_id = false)
{
$this->history = false;
$venue = new Venue_Model((int) $venue_id);
// Check access
if (!($venue->loaded() && $venue->has_access(Venue_Model::ACCESS_EDIT)) && !(!$venue->loaded() && $this->visitor->logged_in(array('admin', 'venue moderator', 'venue')))) {
url::back('venues');
}
$errors = $form_errors = array();
$form_values = $venue->as_array();
// check post
if (request::method() == 'post') {
$post = array_merge($this->input->post(), $_FILES);
$extra = array('author_id' => $this->user->id);
// got address, get geocode
if (!empty($post['address']) && !empty($post['city_name'])) {
list($extra['latitude'], $extra['longitude']) = Gmap::address_to_ll(implode(', ', array($post['address'], $post['zip'], $post['city_name'])));
}
if (csrf::valid() && $venue->validate($post, true, $extra)) {
// handle logo upload
if (isset($post->logo) && empty($post->logo['error'])) {
$logo = Image_Model::factory('venues.logo', $post->logo, $this->user->id);
if ($logo->id) {
$venue->add($logo);
$venue->default_image_id = $logo->id;
$venue->save();
}
}
// handle picture uploads
foreach (array($post->picture1, $post->picture2) as $picture) {
if (isset($picture) && empty($picture['error'])) {
$image = Image_Model::factory('venues.image', $picture, $this->user->id);
if ($image->id) {
$venue->add($image);
$venue->save();
}
}
}
// update tags
$venue->remove(ORM::factory('tag'));
if (!empty($post->tags)) {
foreach ($post->tags as $tag_id => $tag) {
$venue->add(ORM::factory('tag', $tag_id));
}
}
url::redirect(url::model($venue));
} else {
$form_errors = $post->errors();
}
$form_values = arr::overwrite($form_values, $post->as_array());
}
// editing old?
if ($venue_id) {
if ($venue->has_access(Venue_Model::ACCESS_DELETE)) {
$this->page_actions[] = array('link' => 'venue/' . url::title($venue->id, $venue->name) . '/delete/?token=' . csrf::token(), 'text' => __('Delete venue'), 'class' => 'venue-delete');
}
$this->page_subtitle = __('Edit venue');
if (!$venue->id) {
$errors = array('venues.error_venue_not_found');
} else {
$venue_category = $venue->venue_category;
}
} else {
$this->page_subtitle = __('Add venue');
if ($category_id) {
$venue_category = new Venue_Category_Model((int) $category_id);
if ($venue_category->id) {
$form_values['venue_category_id'] = $venue_category->id;
} else {
$errors = array('venues.error_venue_category_not_found');
}
}
}
$this->page_actions[] = array('link' => 'venue/' . url::title($venue->id, $venue->name), 'text' => __('Cancel'), 'class' => 'cancel');
$this->breadcrumb[] = html::anchor('/venues/' . url::title($venue_category->id, $venue_category->name), $venue_category->name);
if ($venue->id) {
$this->breadcrumb[] = html::anchor('/venue/' . url::title($venue->id, $venue->name), $venue->name);
}
// show form
if (empty($errors)) {
$form = array();
// tags
if ($venue_category->tag_group_id) {
$form['tags'] = $form_values['tags'] = array();
foreach ($venue_category->tag_group->tags as $tag) {
$form['tags'][$tag->id] = $tag->name;
if ($venue->has($tag)) {
$form_values['tags'][$tag->id] = $tag->name;
}
}
}
$venue_categories = ORM::factory('venue_category')->find_all()->select_list('id', 'name');
$form['venue_category_id'] = $venue_categories;
widget::add('main', View_Mod::factory('venues/venue_edit', array('form' => $form, 'values' => $form_values, 'errors' => $form_errors)));
//.........这里部分代码省略.........
示例10: out
/**
* Sign out
*/
public function out()
{
$this->history = false;
$this->visitor->logout();
// Redirect back to the login page
url::back();
}