本文整理汇总了PHP中html::user方法的典型用法代码示例。如果您正苦于以下问题:PHP html::user方法的具体用法?PHP html::user怎么用?PHP html::user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类html
的用法示例。
在下文中一共展示了html::user方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Get newsfeed item as HTML
*
* @param Newsfeed_Model $item
* @return string
*/
public static function get(NewsFeedItem_Model $item)
{
$text = '';
switch ($item->type) {
case self::TYPE_FRIEND:
$friend = ORM::factory('user')->find_user($item->data['friend_id']);
if ($friend->id) {
$text = __('added :friend as a friend', array(':friend' => html::user($friend)));
}
break;
case self::TYPE_LOGIN:
$text = __('logged in');
break;
}
return $text;
}
示例2: bbcode_quote
/**
* Handle forum quotations
*
* @param BBCode $bbcode
* @param string $action
* @param string $name
* @param string $default
* @param array $params
* @param string $content
* @return string
*/
public function bbcode_quote($bbcode, $action, $name, $default, $params, $content)
{
// Pass all to 2nd phase
if ($action == BBCODE_CHECK) {
return true;
}
// Parse parameters
foreach ($params['_params'] as $param) {
switch ($param['key']) {
// Parent post id
case 'post':
$post_id = (int) $param['value'];
$post = ORM::factory('forum_post', $post_id);
break;
// Parent post author
// Parent post author
case 'author':
$author_name = $param['value'];
$author = ORM::factory('user')->find_user($author_name);
break;
}
}
// Add parent post
if (isset($post) && $post->id) {
$quote = '<blockquote cite="' . url::model($post->forum_topic) . '/' . $post->id . '#post-' . $post->id . '">';
// Override author
$author = $post->author;
} else {
$quote = '<blockquote>';
}
$quote .= '<p>' . trim($content) . '</p>';
// Post author
if (isset($author) && $author->id) {
$quote .= '<cite>' . __('-- :author', array(':author' => html::user($author))) . '</cite>';
} else {
if (isset($author_name)) {
$quote .= '<cite>' . __('-- :author', array(':author' => html::specialchars($author_name))) . '</cite>';
}
}
$quote .= '</blockquote>';
return $quote;
}
示例3: _view
/**
* User profile
*/
public function _view()
{
$this->tab_id = 'profile';
$owner = $this->user && $this->member->id == $this->user->id;
if ($owner && $this->user->newcomments) {
$this->user->newcomments = 0;
$this->user->save();
}
// Actions
if ($this->member->has_access(User_Model::ACCESS_EDIT)) {
$this->page_actions[] = array('link' => url::user($this->member) . '/edit', 'text' => __('Settings'), 'class' => 'settings');
}
// Picture
widget::add('side', View_Mod::factory('member/member', array('mod_class' => 'member member-' . $this->member->id, 'user' => $this->member)));
// Comments
if ($this->member->has_access(User_Model::ACCESS_COMMENT)) {
$comment = new User_Comment_Model();
$form_values = $comment->as_array();
$form_errors = array();
// check post
if (csrf::valid() && ($post = $this->input->post())) {
$comment->user_id = $this->member->id;
$comment->author_id = $this->user->id;
$comment->comment = $post['comment'];
if (isset($post['private'])) {
$comment->private = 1;
}
try {
$comment->save();
if (!$owner) {
$this->member->newcomments += 1;
$this->member->save();
}
$this->user->commentsleft += 1;
$this->user->save();
if (!request::is_ajax()) {
url::redirect(url::current());
}
} catch (ORM_Validation_Exception $e) {
$form_errors = $e->validation->errors();
$form_values = arr::overwrite($form_values, $post);
}
}
// Handle pagination
$per_page = 25;
$page_num = $this->uri->segment('page') ? $this->uri->segment('page') : 1;
$page_offset = ($page_num - 1) * $per_page;
$total_comments = $this->member->get_comment_count();
$comments = $this->member->find_comments($page_num, $per_page, $this->user);
$pagination = new Pagination(array('items_per_page' => $per_page, 'total_items' => $total_comments));
$view = View::factory('generic/comments', array('delete' => '/member/comment/%d/delete/?token=' . csrf::token(), 'private' => '/member/comment/%d/private/?token=' . csrf::token(), 'comments' => $comments, 'errors' => $form_errors, 'values' => $form_values, 'pagination' => $pagination, 'user' => $this->user));
if (request::is_ajax()) {
echo $view;
return;
}
widget::add('main', $view);
}
// Basic info
$basic_info = array();
if (!empty($this->member->name)) {
$basic_info[__('Name')] = html::specialchars($this->member->name);
}
if (!empty($this->member->city_name)) {
$basic_info[__('City')] = html::specialchars($this->member->city_name);
}
if (!empty($this->member->dob) && $this->member->dob != '0000-00-00') {
$basic_info[__('Date of Birth')] = __(':dob (:years years)', array(':dob' => date::format('DMYYYY', $this->member->dob), ':years' => date::timespan(strtotime($this->member->dob), null, 'years')));
}
if (!empty($this->member->gender)) {
$basic_info[__('Gender')] = $this->member->gender == 'm' ? __('Male') : __('Female');
}
if (!empty($this->member->latitude) && !empty($this->member->longitude)) {
$basic_info[__('Location')] = $this->member->latitude . ', ' . $this->member->longitude;
$basic_info[__('Location')] = html::anchor('#map', __('Toggle map'), array('class' => 'expander', 'title' => __('Show/hide'))) . '<div id="map" style="display: none">' . __('Map loading') . '</div>';
$map = new Gmap('map', array('ScrollWheelZoom' => true));
$map->center($this->member->latitude, $this->member->longitude, 15)->controls('small')->types();
$map->add_marker($this->member->latitude, $this->member->longitude, html::avatar($this->member->avatar, $this->member->username) . html::user($this->member));
widget::add('foot', html::script_source($map->render('gmaps/jquery_event')));
widget::add('foot', html::script_source("\$('a[href*=\"#map\"]:first').click(function() { \$('#map').toggle('normal', gmap_open); return false; });"));
}
// Site info
$site_info = array(__('Registered') => date::format('DMYYYY_HM', $this->member->created) . ' [#' . $this->member->id . ']', __('Logins') => __(':logins (:ago ago)', array(':logins' => number_format($this->member->logins, 0), ':ago' => '<abbr title="' . date::format('DMYYYY_HM', $this->member->last_login) . '">' . date::timespan_short($this->member->last_login) . '</abbr>')), __('Posts') => number_format($this->member->posts, 0), __('Comments') => number_format($this->member->commentsleft, 0));
// Initialize tabs
$tabs = array('basic-info' => array('href' => '#basic-info', 'title' => __('Basic info'), 'tab' => new View('generic/list_info', array('id' => 'basic-info', 'title' => __('Basic info'), 'list' => $basic_info))), 'site-info' => array('href' => '#site-info', 'title' => __('Site info'), 'tab' => new View('generic/list_info', array('id' => 'site-info', 'title' => __('Site info'), 'list' => $site_info))));
widget::add('side', View::factory('generic/tabs', array('id' => 'info-tab', 'tabs' => $tabs)));
$this->_side_views();
}
示例4: __
<?php
if ($topic->has_access(Forum_Topic_Model::ACCESS_WRITE)) {
?>
<?php
echo html::anchor('forum/post/' . $post->id . '/quote', __('Quote'), array('class' => 'action post-quote'));
?>
<?php
}
?>
</span>
<span class="details">
<?php
echo __(':user, :ago ago', array(':user' => html::user($post->author_id, $post->author_name), ':ago' => html::time(date::timespan_short($post->created), $post->created)));
?>
<?php
if ($post->modifies > 0) {
?>
<br />
<?php
echo __('Edited :ago ago', array(':ago' => html::time(date::timespan_short($post->modified), $post->modified)));
?>
<?php
}
?>
<?php
if ($post->parent_id) {
$parent_topic = $post->parent->forum_topic;
?>
示例5: entry
/**
* Single blog entry
*
* @param mixed $entry_id or add
* @param string $action
*/
public function entry($entry_id, $action = false)
{
// Add new entry
if ($entry_id == 'add') {
$this->_entry_edit();
return;
} else {
if ($action) {
switch ($action) {
// Delete entry
case 'delete':
$this->_entry_delete($entry_id);
return;
// Edit event
// Edit event
case 'edit':
$this->_entry_edit($entry_id);
return;
}
}
}
$entry = new Blog_Entry_Model((int) $entry_id);
$errors = $entry->id ? array() : __('Blog entry found :entry', array(':entry' => $entry_id));
if (empty($errors)) {
$this->breadcrumb[] = html::anchor(url::model($entry), $entry->name);
$this->page_title = text::title($entry->name);
$this->page_subtitle = __('By :user :ago ago', array(':user' => html::user($entry->author), ':ago' => html::time(date::timespan_short($entry->created), $entry->created)));
if ($entry->is_author() || $this->visitor->logged_in('admin')) {
$this->page_actions[] = array('link' => url::model($entry) . '/delete/?token=' . csrf::token($this->user->id), 'text' => __('Delete entry'), 'class' => 'entry-delete');
$this->page_actions[] = array('link' => url::model($entry) . '/edit', 'text' => __('Edit entry'), 'class' => 'entry-edit');
}
widget::add('main', View::factory('blog/entry', array('entry' => $entry)));
// Blog comments
if ($this->visitor->logged_in()) {
$comment = new Blog_Comment_Model();
$form_values = $comment->as_array();
$form_errors = array();
// check post
if (csrf::valid() && ($post = $this->input->post())) {
$comment->blog_entry_id = $entry->id;
$comment->user_id = $entry->author->id;
$comment->author_id = $this->user->id;
$comment->comment = $post['comment'];
if (isset($post['private'])) {
$comment->private = 1;
}
try {
$comment->save();
$entry->comments++;
$entry->newcomments++;
$entry->save();
if (!$comment->private) {
newsfeeditem_blog::comment($this->user, $entry);
}
if (!request::is_ajax()) {
url::redirect(url::current());
}
} catch (ORM_Validation_Exception $e) {
$form_errors = $e->validation->errors();
$form_values = arr::overwrite($form_values, $post);
}
}
$comments = $entry->find_comments();
$view = View::factory('generic/comments', array('delete' => '/blogs/comment/%d/delete/?token=' . csrf::token(), 'private' => '/blogs/comment/%d/private/?token=' . csrf::token(), 'comments' => $comments, 'errors' => $form_errors, 'values' => $form_values, 'pagination' => null, 'user' => $this->user));
if (request::is_ajax()) {
echo $view;
return;
}
widget::add('main', $view);
}
if (!$entry->is_author()) {
$entry->views++;
$entry->save();
}
}
if (count($errors)) {
$this->_error(Kohana::lang('generic.error'), $errors);
}
}
示例6: __
*/
?>
<section class="mod gallery-image-info">
<div>
<dl>
<dt><?php
echo __('Details');
?>
</dt>
<?php
if ($image->author_id) {
?>
<dd><?php
echo __('Copyright © :year :author', array(':year' => date('Y', strtotime($image->created)), ':author' => html::user($image->author)));
?>
</dd>
<?php
}
?>
<dd><?php
echo __('Added: :date', array(':date' => '<var>' . date::format('DMYYYY_HM', $image->created) . '</var>'));
?>
</dd>
<dd><?php
echo __('Image size: :size kB', array(':size' => '<var>' . text::bytes($image->original_size, 'KiB', '%01.2f') . '</var>'));
?>
</dd>
<dd><?php
echo __('Resolution: :resolution', array(':resolution' => sprintf('<var>%d×%d</var>', $image->original_width, $image->original_height)));
示例7: __
<li class="unit size1of2"><?php
echo html::icon_value(array(':topics' => $area->topics), ':topics topic', ':topics topics', 'topics');
?>
</li>
<li class="unit size1of2"><?php
echo html::icon_value(array(':posts' => $area->posts), ':posts post', ':posts posts', 'posts');
?>
</li>
</ul>
</header>
<footer>
<?php
if ($area->topics > 0) {
?>
<?php
echo __('Last post in :area by :user :ago ago', array(':area' => html::anchor(url::model($area->last_topic) . '/page/last#last', text::limit_chars(text::title($area->last_topic->name), 20, '…', true), array('title' => html::specialchars($area->last_topic->name))), ':user' => html::user(null, $area->last_topic->last_poster), ':ago' => html::time(date::timespan_short($area->last_topic->last_posted), $area->last_topic->last_posted)));
?>
<?php
} else {
?>
<sup><?php
echo __('No topics found');
?>
</sup>
<?php
}
?>
</footer>
</article>
<?php
示例8: foreach
*
* @package Blog
* @author Antti Qvickström
* @copyright (c) 2010 Antti Qvickström
* @license http://www.opensource.org/licenses/mit-license.php MIT license
*/
?>
<?php
foreach ($entries as $entry) {
?>
<article>
<header>
<?php
echo html::avatar($entry->author->avatar, $entry->author->username);
?>
<h4><?php
echo html::anchor(url::model($entry), text::title($entry->name), array('title' => $entry->name));
?>
</h4>
<span class="details">
<?php
echo __('By :user :ago ago', array(':user' => html::user($entry->author), ':ago' => html::time(date::timespan_short($entry->created), $entry->created)));
?>
</span>
</header>
</article>
<?php
}
示例9: foreach
* @author Antti Qvickström
* @copyright (c) 2010 Antti Qvickström
* @license http://www.opensource.org/licenses/mit-license.php MIT license
*/
?>
<ul>
<?php
foreach ($newsfeed as $item) {
?>
<li class="clearfix">
<?php
echo html::avatar($item['user']->avatar, $item['user']->username);
?>
<?php
echo html::user($item['user']);
?>
<?php
echo $item['text'];
?>
<?php
echo __(':ago ago', array(':ago' => html::time(date::timespan_short($item['stamp']), $item['stamp'])));
?>
</li>
<?php
}
?>
</ul>
示例10: foreach
<li class="day">
<header class="unit size1of6">
<?php
echo html::box_day($date);
?>
</header>
<ul class="unit size5of6 lastunit">
<?php
foreach ($date_users as $user) {
?>
<li class="member">
<?php
echo html::user($user);
?>
</li>
<?php
}
?>
</ul>
<br clear="both" />
</li>
<?php
}
?>
</ul>
示例11: array
} else {
?>
<?php
echo html::anchor(url::model($gallery), html::image('http://' . Kohana::config('site.image_server') . '/kuvat/' . $gallery->dir . '/pieni_' . $image->legacy_filename), array('title' => __('Back to gallery')));
?>
<?php
}
?>
<?php
if ($image->description) {
?>
<?php
$names = array();
foreach (explode(',', $image->description) as $name) {
$names[] = html::user(trim($name));
}
?>
<footer>
<?php
echo __('In picture: :users', array(':users' => implode(', ', $names)));
?>
</footer>
<?php
}
?>
</div>
</section>
<?php
echo html::script_source('
$(document).keyup(function(e) {
示例12: array
<div class="users">
<?php
// Build short (friends) and long (others) user list
$short = $long = array();
foreach ($users as $user) {
$user = $user instanceof User ? $user : ORM::factory('user')->find_user($user);
if ($viewer && $viewer->is_friend($user)) {
$short[mb_strtoupper($user->username)] = html::user($user);
} else {
$long[mb_strtoupper($user->username)] = html::user($user);
}
}
ksort($long);
// If no friends, pick random from long
if (empty($short) && !empty($long)) {
$shorts = (array) array_rand($long, min(10, count($long)));
foreach ($shorts as $move) {
$short[$move] = $long[$move];
unset($long[$move]);
}
}
ksort($short);
?>
<?php
if (count($short)) {
?>
<?php
echo implode(', ', $short);
?>
示例13: __
* @license http://www.opensource.org/licenses/mit-license.php MIT license
*/
?>
<h4><?php
echo __('Birthdays');
?>
</h4>
<?php
if (empty($birthdays)) {
?>
<span class="notice"><?php
echo __('No birthdays today');
?>
</span>
<?php
} else {
foreach ($birthdays as $age => $birthday) {
$users = array();
?>
<h5><?php
echo __(':years years', array(':years' => $age));
?>
</h5>
<?php
foreach ($birthday as $user) {
$users[] = html::user($user->id, $user->username);
}
echo join(', ', $users);
}
}
示例14: foreach
* @author Antti Qvickström
* @copyright (c) 2010 Antti Qvickström
* @license http://www.opensource.org/licenses/mit-license.php MIT license
*/
?>
<ul>
<?php
foreach ($shouts as $shout) {
?>
<li><?php
echo html::time(date::format('HHMM', $shout->created), $shout->created);
?>
<?php
echo html::user($shout->author);
?>
: <?php
echo html::chars($shout->shout);
?>
</li>
<?php
}
?>
</ul>
<?php
if ($can_shout) {
?>