本文整理汇总了PHP中format_like函数的典型用法代码示例。如果您正苦于以下问题:PHP format_like函数的具体用法?PHP format_like怎么用?PHP format_like使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了format_like函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: conversation
//.........这里部分代码省略.........
}
}
}
}
$likebuttons = '';
$shareable = $profile_owner == local_user() && !$item['private'] ? true : false;
//($mode != 'display') &&
if ($page_writeable) {
if ($toplevelpost) {
$likebuttons = array('like' => array(t("I like this (toggle)"), t("like")), 'dislike' => array(t("I don't like this (toggle)"), t("dislike")));
if ($shareable) {
$likebuttons['share'] = array(t('Share this'), t('share'));
}
}
$qc = $qcomment = null;
if (in_array('qcomment', $a->plugins)) {
$qc = local_user() ? get_pconfig(local_user(), 'qcomment', 'words') : null;
$qcomment = $qc ? explode("\n", $qc) : null;
}
if ($show_comment_box || $show_comment_box == false && $override_comment_box == false && $item['last-child']) {
$comment = replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $mode === 'display' ? $_SESSION['return_url'] : '', '$type' => $mode === 'profile' ? 'wall-comment' : 'net-comment', '$id' => $item['item_id'], '$parent' => $item['parent'], '$qcomment' => $qcomment, '$profile_uid' => $profile_owner, '$mylink' => $a->contact['url'], '$mytitle' => t('This is you'), '$myphoto' => $a->contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$edbold' => t('Bold'), '$editalic' => t('Italic'), '$eduline' => t('Underline'), '$edquote' => t('Quote'), '$edcode' => t('Code'), '$edimg' => t('Image'), '$edurl' => t('Link'), '$edvideo' => t('Video'), '$preview' => t('Preview'), '$ww' => $mode === 'network' ? $commentww : ''));
}
}
if (local_user() && link_compare($a->contact['url'], $item['author-link'])) {
$edpost = array($a->get_baseurl($ssl_state) . "/editpost/" . $item['id'], t("Edit"));
} else {
$edpost = false;
}
$drop = '';
$dropping = false;
if (intval($item['contact-id']) && $item['contact-id'] == remote_user() || $item['uid'] == local_user()) {
$dropping = true;
}
$drop = array('dropping' => $dropping, 'select' => t('Select'), 'delete' => t('Delete'));
$star = false;
$filer = false;
$isstarred = "unstarred";
if ($profile_owner == local_user()) {
if ($toplevelpost) {
$isstarred = $item['starred'] ? "starred" : "unstarred";
$star = array('do' => t("add star"), 'undo' => t("remove star"), 'toggle' => t("toggle star status"), 'classdo' => $item['starred'] ? "hidden" : "", 'classundo' => $item['starred'] ? "" : "hidden", 'starred' => t('starred'), 'tagger' => t("add tag"), 'classtagger' => "");
}
$filer = t("save to folder");
}
$photo = $item['photo'];
$thumb = $item['thumb'];
// Post was remotely authored.
$diff_author = link_compare($item['url'], $item['author-link']) ? false : true;
$profile_name = strlen($item['author-name']) && $diff_author ? $item['author-name'] : $item['name'];
if ($item['author-link'] && !$item['author-name']) {
$profile_name = $item['author-link'];
}
$sp = false;
$profile_link = best_link_url($item, $sp);
if ($profile_link === 'mailbox') {
$profile_link = '';
}
if ($sp) {
$sparkle = ' sparkle';
} else {
$profile_link = zrl($profile_link);
}
$normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']);
if ($normalised != 'mailbox' && x($a->contacts, $normalised)) {
$profile_avatar = $a->contacts[$normalised]['thumb'];
} else {
$profile_avatar = strlen($item['author-avatar']) && $diff_author ? $item['author-avatar'] : $thumb;
}
$like = x($alike, $item['id']) ? format_like($alike[$item['id']], $alike[$item['id'] . '-l'], 'like', $item['id']) : '';
$dislike = x($dlike, $item['id']) ? format_like($dlike[$item['id']], $dlike[$item['id'] . '-l'], 'dislike', $item['id']) : '';
$locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
call_hooks('render_location', $locate);
$location = strlen($locate['html']) ? $locate['html'] : render_location_google($locate);
$indent = $toplevelpost ? '' : ' comment';
if (strcmp(datetime_convert('UTC', 'UTC', $item['created']), datetime_convert('UTC', 'UTC', 'now - 12 hours')) > 0) {
$indent .= ' shiny';
}
//
localize_item($item);
$tags = array();
foreach (explode(',', $item['tag']) as $tag) {
$tag = trim($tag);
if ($tag != "") {
$tags[] = bbcode($tag);
}
}
// Build the HTML
$body = prepare_body($item, true);
//$tmp_item = replace_macros($template,
$tmp_item = array('comment_firstcollapsed' => $comment_firstcollapsed, 'comment_lastcollapsed' => $comment_lastcollapsed, 'template' => $template, 'type' => implode("", array_slice(explode("/", $item['verb']), -1)), 'tags' => $tags, 'body' => template_escape($body), 'text' => strip_tags(template_escape($body)), 'id' => $item['item_id'], 'linktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, strlen($item['author-link']) ? $item['author-link'] : $item['url']), 'olinktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, strlen($item['owner-link']) ? $item['owner-link'] : $item['url']), 'to' => t('to'), 'wall' => t('Wall-to-Wall'), 'vwall' => t('via Wall-To-Wall:'), 'profile_url' => $profile_link, 'item_photo_menu' => item_photo_menu($item), 'name' => template_escape($profile_name), 'thumb' => $profile_avatar, 'osparkle' => $osparkle, 'sparkle' => $sparkle, 'title' => template_escape($item['title']), 'ago' => $item['app'] ? sprintf(t('%s from %s'), relative_date($item['created']), $item['app']) : relative_date($item['created']), 'lock' => $lock, 'location' => template_escape($location), 'indent' => $indent, 'owner_url' => $owner_url, 'owner_photo' => $owner_photo, 'owner_name' => template_escape($owner_name), 'plink' => get_plink($item), 'edpost' => $edpost, 'isstarred' => $isstarred, 'star' => $star, 'filer' => $filer, 'drop' => $drop, 'vote' => $likebuttons, 'like' => $like, 'dislike' => $dislike, 'comment' => $comment, 'previewing' => $previewing, 'wait' => t('Please wait'));
$arr = array('item' => $item, 'output' => $tmp_item);
call_hooks('display_item', $arr);
$threads[$threadsid]['items'][] = $arr['output'];
}
}
}
$page_template = get_markup_template("conversation.tpl");
$o = replace_macros($page_template, array('$baseurl' => $a->get_baseurl($ssl_state), '$mode' => $mode, '$user' => $a->user, '$threads' => $threads, '$dropping' => $dropping ? t('Delete Selected Items') : False));
return $o;
}
示例2: get_template_data
//.........这里部分代码省略.........
if ($consensus) {
$response_verbs[] = 'agree';
$response_verbs[] = 'disagree';
$response_verbs[] = 'abstain';
if ($this->is_commentable()) {
$conlabels = array(t('I agree'), t('I disagree'), t('I abstain'));
$canvote = true;
}
}
if (!feature_enabled($conv->get_profile_owner(), 'dislike')) {
unset($conv_responses['dislike']);
}
$responses = get_responses($conv_responses, $response_verbs, $this, $item);
$like_count = x($conv_responses['like'], $item['mid']) ? $conv_responses['like'][$item['mid']] : '';
$like_list = x($conv_responses['like'], $item['mid']) ? $conv_responses['like'][$item['mid'] . '-l'] : '';
if (count($like_list) > MAX_LIKERS) {
$like_list_part = array_slice($like_list, 0, MAX_LIKERS);
array_push($like_list_part, '<a href="#" data-toggle="modal" data-target="#likeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>');
} else {
$like_list_part = '';
}
$like_button_label = tt('Like', 'Likes', $like_count, 'noun');
if (feature_enabled($conv->get_profile_owner(), 'dislike')) {
$dislike_count = x($conv_responses['dislike'], $item['mid']) ? $conv_responses['dislike'][$item['mid']] : '';
$dislike_list = x($conv_responses['dislike'], $item['mid']) ? $conv_responses['dislike'][$item['mid'] . '-l'] : '';
$dislike_button_label = tt('Dislike', 'Dislikes', $dislike_count, 'noun');
if (count($dislike_list) > MAX_LIKERS) {
$dislike_list_part = array_slice($dislike_list, 0, MAX_LIKERS);
array_push($dislike_list_part, '<a href="#" data-toggle="modal" data-target="#dislikeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>');
} else {
$dislike_list_part = '';
}
}
$showlike = x($conv_responses['like'], $item['mid']) ? format_like($conv_responses['like'][$item['mid']], $conv_responses['like'][$item['mid'] . '-l'], 'like', $item['mid']) : '';
$showdislike = x($conv_responses['dislike'], $item['mid']) && feature_enabled($conv->get_profile_owner(), 'dislike') ? format_like($conv_responses['dislike'][$item['mid']], $conv_responses['dislike'][$item['mid'] . '-l'], 'dislike', $item['mid']) : '';
/*
* We should avoid doing this all the time, but it depends on the conversation mode
* And the conv mode may change when we change the conv, or it changes its mode
* Maybe we should establish a way to be notified about conversation changes
*/
$this->check_wall_to_wall();
if ($this->is_toplevel()) {
// FIXME check this permission
if ($conv->get_profile_owner() == local_channel() && !array_key_exists('real_uid', $item)) {
// FIXME we don't need all this stuff, some can be done in the template
$star = array('do' => t("Add Star"), 'undo' => t("Remove Star"), 'toggle' => t("Toggle Star Status"), 'classdo' => intval($item['item_starred']) ? "hidden" : "", 'classundo' => intval($item['item_starred']) ? "" : "hidden", 'isstarred' => intval($item['item_starred']) ? "starred icon-star" : "unstarred icon-star-empty", 'starred' => t('starred'));
}
} else {
$indent = 'comment';
}
$verified = intval($item['item_verified']) ? t('Message signature validated') : '';
$forged = $item['sig'] && !intval($item['item_verified']) ? t('Message signature incorrect') : '';
$unverified = '';
// (($this->is_wall_to_wall() && (! intval($item['item_verified']))) ? t('Message cannot be verified') : '');
// FIXME - check this permission
if ($conv->get_profile_owner() == local_channel()) {
$tagger = array('tagit' => t("Add Tag"), 'classtagger' => "");
}
$has_bookmarks = false;
if (is_array($item['term'])) {
foreach ($item['term'] as $t) {
if ($t['type'] == TERM_BOOKMARK) {
$has_bookmarks = true;
}
}
}
示例3: conversation
//.........这里部分代码省略.........
}
if (!$item['wall'] && strlen($item['owner-link']) && $item['owner-link'] != $item['author-link']) {
// Could be anybody.
$owner_url = $item['owner-link'];
$owner_photo = $item['owner-avatar'];
$owner_name = $item['owner-name'];
$template = $wallwall;
$commentww = 'ww';
// If it is our contact, use a friendly redirect link
if (link_compare($item['owner-link'], $item['url']) && $item['network'] === 'dfrn') {
$owner_url = $redirect_url;
$osparkle = ' sparkle';
}
}
}
$likebuttons = '';
$shareable = $profile_owner == local_user() && $mode != 'display' && !$item['private'] ? true : false;
if ($page_writeable) {
if ($toplevelpost) {
$likebuttons = array('like' => array(t("I like this (toggle)"), t("like")), 'dislike' => array(t("I don't like this (toggle)"), t("dislike")));
if ($shareable) {
$likebuttons['share'] = array(t('Share this'), t('share'));
}
}
if ($show_comment_box || $show_comment_box == false && $override_comment_box == false && $item['last-child']) {
$comment = replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $mode === 'display' ? $_SESSION['return_url'] : '', '$type' => $mode === 'profile' ? 'wall-comment' : 'net-comment', '$id' => $item['item_id'], '$parent' => $item['parent'], '$profile_uid' => $profile_owner, '$mylink' => $a->contact['url'], '$mytitle' => t('This is you'), '$myphoto' => $a->contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), '$ww' => $mode === 'network' ? $commentww : ''));
}
}
$edpost = $profile_owner == local_user() && $toplevelpost && intval($item['wall']) == 1 || $mode === 'notes' ? array($a->get_baseurl() . "/editpost/" . $item['id'], t("Edit")) : False;
$drop = '';
$dropping = false;
if (intval($item['contact-id']) && $item['contact-id'] == remote_user() || $item['uid'] == local_user()) {
$dropping = true;
}
$drop = array('dropping' => $dropping, 'select' => t('Select'), 'delete' => t('Delete'));
$star = false;
$isstarred = "unstarred";
if ($profile_owner == local_user() && $toplevelpost) {
$isstarred = $item['starred'] ? "starred" : "unstarred";
$star = array('do' => t("add star"), 'undo' => t("remove star"), 'toggle' => t("toggle star status"), 'classdo' => $item['starred'] ? "hidden" : "", 'classundo' => $item['starred'] ? "" : "hidden", 'starred' => t('starred'), 'tagger' => t("add tag"), 'classtagger' => "");
}
$photo = $item['photo'];
$thumb = $item['thumb'];
// Post was remotely authored.
$diff_author = link_compare($item['url'], $item['author-link']) ? false : true;
$profile_name = strlen($item['author-name']) && $diff_author ? $item['author-name'] : $item['name'];
if ($item['author-link'] && !$item['author-name']) {
$profile_name = $item['author-link'];
}
$sp = false;
$profile_link = best_link_url($item, $sp);
if ($sp) {
$sparkle = ' sparkle';
}
if ($profile_link === 'mailbox') {
$profile_link = '';
}
$normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']);
if ($normalised != 'mailbox' && x($a->contacts, $normalised)) {
$profile_avatar = $a->contacts[$normalised]['thumb'];
} else {
$profile_avatar = strlen($item['author-avatar']) && $diff_author ? $item['author-avatar'] : $thumb;
}
$like = x($alike, $item['id']) ? format_like($alike[$item['id']], $alike[$item['id'] . '-l'], 'like', $item['id']) : '';
$dislike = x($dlike, $item['id']) ? format_like($dlike[$item['id']], $dlike[$item['id'] . '-l'], 'dislike', $item['id']) : '';
$location = $item['location'] ? '<a target="map" title="' . $item['location'] . '" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '';
$coord = $item['coord'] ? '<a target="map" title="' . $item['coord'] . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '';
if ($coord) {
if ($location) {
$location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
} else {
$location = '<span class="smalltext">' . $coord . '</span>';
}
}
$indent = $toplevelpost ? '' : ' comment';
if (strcmp(datetime_convert('UTC', 'UTC', $item['created']), datetime_convert('UTC', 'UTC', 'now - 12 hours')) > 0) {
$indent .= ' shiny';
}
//
localize_item($item);
$tags = array();
foreach (explode(',', $item['tag']) as $tag) {
$tag = trim($tag);
if ($tag != "") {
$tags[] = bbcode($tag);
}
}
// Build the HTML
$body = prepare_body($item, true);
$tmp_item = replace_macros($template, array('$type' => implode("", array_slice(split("/", $item['verb']), -1)), '$tags' => $tags, '$body' => template_escape($body), '$id' => $item['item_id'], '$linktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, strlen($item['author-link']) ? $item['author-link'] : $item['url']), '$olinktitle' => sprintf(t('View %s\'s profile @ %s'), $profile_name, strlen($item['owner-link']) ? $item['owner-link'] : $item['url']), '$to' => t('to'), '$wall' => t('Wall-to-Wall'), '$vwall' => t('via Wall-To-Wall:'), '$profile_url' => $profile_link, '$item_photo_menu' => item_photo_menu($item), '$name' => template_escape($profile_name), '$thumb' => $profile_avatar, '$osparkle' => $osparkle, '$sparkle' => $sparkle, '$title' => template_escape($item['title']), '$ago' => $item['app'] ? sprintf(t('%s from %s'), relative_date($item['created']), $item['app']) : relative_date($item['created']), '$lock' => $lock, '$location' => template_escape($location), '$indent' => $indent, '$owner_url' => $owner_url, '$owner_photo' => $owner_photo, '$owner_name' => template_escape($owner_name), '$plink' => get_plink($item), '$edpost' => $edpost, '$isstarred' => $isstarred, '$star' => $star, '$drop' => $drop, '$vote' => $likebuttons, '$like' => $like, '$dislike' => $dislike, '$comment' => $comment, '$wait' => t('Please wait')));
$arr = array('item' => $item, 'output' => $tmp_item);
call_hooks('display_item', $arr);
$threads[$threadsid]['html'] .= $arr['output'];
}
}
}
$page_template = get_markup_template("conversation.tpl");
$o .= replace_macros($page_template, array('$threads' => $threads, '$dropping' => $dropping ? t('Delete Selected Items') : False));
return $o;
}
示例4: photos_content
//.........这里部分代码省略.........
if ($can_post || $can_comment) {
$commentbox = replace_macros($cmnt_tpl, array('$return_path' => '', '$mode' => 'photos', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, '$mylink' => $observer['xchan_url'], '$mytitle' => t('This is you'), '$myphoto' => $observer['xchan_photo_s'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), '$ww' => '', '$feature_encrypt' => false));
}
}
$alike = array();
$dlike = array();
$like = '';
$dislike = '';
$conv_responses = array('like' => array('title' => t('Likes', 'title')), 'dislike' => array('title' => t('Dislikes', 'title')), 'agree' => array('title' => t('Agree', 'title')), 'disagree' => array('title' => t('Disagree', 'title')), 'abstain' => array('title' => t('Abstain', 'title')), 'attendyes' => array('title' => t('Attending', 'title')), 'attendno' => array('title' => t('Not attending', 'title')), 'attendmaybe' => array('title' => t('Might attend', 'title')));
if ($r) {
foreach ($r as $item) {
builtin_activity_puller($item, $conv_responses);
}
$like_count = x($alike, $link_item['mid']) ? $alike[$link_item['mid']] : '';
$like_list = x($alike, $link_item['mid']) ? $alike[$link_item['mid'] . '-l'] : '';
if (count($like_list) > MAX_LIKERS) {
$like_list_part = array_slice($like_list, 0, MAX_LIKERS);
array_push($like_list_part, '<a href="#" data-toggle="modal" data-target="#likeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>');
} else {
$like_list_part = '';
}
$like_button_label = tt('Like', 'Likes', $like_count, 'noun');
//if (feature_enabled($conv->get_profile_owner(),'dislike')) {
$dislike_count = x($dlike, $link_item['mid']) ? $dlike[$link_item['mid']] : '';
$dislike_list = x($dlike, $link_item['mid']) ? $dlike[$link_item['mid'] . '-l'] : '';
$dislike_button_label = tt('Dislike', 'Dislikes', $dislike_count, 'noun');
if (count($dislike_list) > MAX_LIKERS) {
$dislike_list_part = array_slice($dislike_list, 0, MAX_LIKERS);
array_push($dislike_list_part, '<a href="#" data-toggle="modal" data-target="#dislikeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>');
} else {
$dislike_list_part = '';
}
//}
$like = isset($alike[$link_item['mid']]) ? format_like($alike[$link_item['mid']], $alike[$link_item['mid'] . '-l'], 'like', $link_item['mid']) : '';
$dislike = isset($dlike[$link_item['mid']]) ? format_like($dlike[$link_item['mid']], $dlike[$link_item['mid'] . '-l'], 'dislike', $link_item['mid']) : '';
// display comments
foreach ($r as $item) {
$comment = '';
$template = $tpl;
$sparkle = '';
if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) {
continue;
}
$redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'];
$profile_url = zid($item['author']['xchan_url']);
$sparkle = '';
$profile_name = $item['author']['xchan_name'];
$profile_avatar = $item['author']['xchan_photo_m'];
$profile_link = $profile_url;
$drop = '';
if ($observer['xchan_hash'] === $item['author_xchan'] || $observer['xchan_hash'] === $item['owner_xchan']) {
$drop = replace_macros(get_markup_template('photo_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
}
$name_e = $profile_name;
$title_e = $item['title'];
unobscure($item);
$body_e = prepare_text($item['body'], $item['mimetype']);
$comments .= replace_macros($template, array('$id' => $item['id'], '$mode' => 'photos', '$profile_url' => $profile_link, '$name' => $name_e, '$thumb' => $profile_avatar, '$sparkle' => $sparkle, '$title' => $title_e, '$body' => $body_e, '$ago' => relative_date($item['created']), '$indent' => $item['parent'] != $item['id'] ? ' comment' : '', '$drop' => $drop, '$comment' => $comment));
}
if ($can_post || $can_comment) {
$commentbox = replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, '$mylink' => $observer['xchan_url'], '$mytitle' => t('This is you'), '$myphoto' => $observer['xchan_photo_s'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$ww' => ''));
}
}
$paginate = paginate($a);
}
$album_e = array($album_link, $ph[0]['album']);
示例5: photos_content
//.........这里部分代码省略.........
}
$edit = Null;
if ($cmd === 'edit' && $can_post) {
$edit_tpl = get_markup_template('photo_edit.tpl');
$edit = replace_macros($edit_tpl, array('$id' => $ph[0]['id'], '$rotate' => t('Rotate CW'), '$album' => template_escape($ph[0]['album']), '$newalbum' => t('New album name'), '$nickname' => $a->data['user']['nickname'], '$resource_id' => $ph[0]['resource-id'], '$capt_label' => t('Caption'), '$caption' => template_escape($ph[0]['desc']), '$tag_label' => t('Add a Tag'), '$tags' => $link_item['tag'], '$permissions' => t('Permissions'), '$aclselect' => template_escape(populate_acl($ph[0])), '$help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'), '$item_id' => count($linked_items) ? $link_item['id'] : 0, '$submit' => t('Submit'), '$delete' => t('Delete Photo')));
}
if (count($linked_items)) {
$cmnt_tpl = get_markup_template('comment_item.tpl');
$tpl = get_markup_template('photo_item.tpl');
$return_url = $a->cmd;
$like_tpl = get_markup_template('like_noshare.tpl');
$likebuttons = '';
if ($can_post || can_write_wall($a, $owner_uid)) {
$likebuttons = replace_macros($like_tpl, array('$id' => $link_item['id'], '$likethis' => t("I like this (toggle)"), '$nolike' => t("I don't like this (toggle)"), '$share' => t('Share'), '$wait' => t('Please wait')));
}
$comments = '';
if (!count($r)) {
if ($can_post || can_write_wall($a, $owner_uid)) {
if ($link_item['last-child']) {
$comments .= replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, '$mylink' => $contact['url'], '$mytitle' => t('This is you'), '$myphoto' => $contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), '$ww' => ''));
}
}
}
$alike = array();
$dlike = array();
$like = '';
$dislike = '';
// display comments
if (count($r)) {
foreach ($r as $item) {
like_puller($a, $item, $alike, 'like');
like_puller($a, $item, $dlike, 'dislike');
}
$like = isset($alike[$link_item['id']]) ? format_like($alike[$link_item['id']], $alike[$link_item['id'] . '-l'], 'like', $link_item['id']) : '';
$dislike = isset($dlike[$link_item['id']]) ? format_like($dlike[$link_item['id']], $dlike[$link_item['id'] . '-l'], 'dislike', $link_item['id']) : '';
if ($can_post || can_write_wall($a, $owner_uid)) {
if ($link_item['last-child']) {
$comments .= replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, '$mylink' => $contact['url'], '$mytitle' => t('This is you'), '$myphoto' => $contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$ww' => ''));
}
}
foreach ($r as $item) {
$comment = '';
$template = $tpl;
$sparkle = '';
if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) {
continue;
}
$redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'];
if ($can_post || can_write_wall($a, $owner_uid)) {
if ($item['last-child']) {
$comments .= replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $item['item_id'], '$parent' => $item['parent'], '$profile_uid' => $owner_uid, '$mylink' => $contact['url'], '$mytitle' => t('This is you'), '$myphoto' => $contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$ww' => ''));
}
}
if (local_user() && $item['contact-uid'] == local_user() && $item['network'] == 'dfrn' && !$item['self']) {
$profile_url = $redirect_url;
$sparkle = ' sparkle';
} else {
$profile_url = $item['url'];
$sparkle = '';
}
$diff_author = $item['url'] !== $item['author-link'] ? true : false;
$profile_name = strlen($item['author-name']) && $diff_author ? $item['author-name'] : $item['name'];
$profile_avatar = strlen($item['author-avatar']) && $diff_author ? $item['author-avatar'] : $item['thumb'];
$profile_link = $profile_url;
$drop = '';
if ($item['contact-id'] == remote_user() || $item['uid'] == local_user()) {
示例6: get_template_data
/**
* Get data in a form usable by a conversation template
*
* Returns:
* _ The data requested on success
* _ false on failure
*/
public function get_template_data($alike, $dlike, $thread_level = 1)
{
require_once "mod/proxy.php";
$result = array();
$a = $this->get_app();
$item = $this->get_data();
$edited = false;
if (strcmp($item['created'], $item['edited']) != 0) {
$edited = array('label' => t('This entry was edited'), 'date' => datetime_convert('UTC', date_default_timezone_get(), $item['edited'], 'r'), 'relative' => relative_date($item['edited']));
}
$commentww = '';
$sparkle = '';
$buttons = '';
$dropping = false;
$star = false;
$ignore = false;
$isstarred = "unstarred";
$indent = '';
$shiny = '';
$osparkle = '';
$total_children = $this->count_descendants();
$conv = $this->get_conversation();
$lock = $item['private'] == 1 || $item['uid'] == local_user() && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) ? t('Private Message') : false;
$shareable = $conv->get_profile_owner() == local_user() && $item['private'] != 1 ? true : false;
if (local_user() && link_compare($a->contact['url'], $item['author-link'])) {
$edpost = array($a->get_baseurl($ssl_state) . "/editpost/" . $item['id'], t("Edit"));
} else {
$edpost = false;
}
if ($this->get_data_value('uid') == local_user() || $this->is_visiting()) {
$dropping = true;
}
$drop = array('dropping' => $dropping, 'pagedrop' => feature_enabled($conv->get_profile_owner(), 'multi_delete') ? $item['pagedrop'] : '', 'select' => t('Select'), 'delete' => t('Delete'));
$filer = $conv->get_profile_owner() == local_user() ? t("save to folder") : false;
$diff_author = link_compare($item['url'], $item['author-link']) ? false : true;
$profile_name = strlen($item['author-name']) && $diff_author ? $item['author-name'] : $item['name'];
if ($item['author-link'] && !$item['author-name']) {
$profile_name = $item['author-link'];
}
$sp = false;
$profile_link = best_link_url($item, $sp);
if ($profile_link === 'mailbox') {
$profile_link = '';
}
if ($sp) {
$sparkle = ' sparkle';
} else {
$profile_link = zrl($profile_link);
}
$normalised = normalise_link(strlen($item['author-link']) ? $item['author-link'] : $item['url']);
if ($normalised != 'mailbox' && x($a->contacts, $normalised)) {
$profile_avatar = $a->contacts[$normalised]['thumb'];
} else {
$profile_avatar = strlen($item['author-avatar']) && $diff_author ? $item['author-avatar'] : $a->get_cached_avatar_image($this->get_data_value('thumb'));
}
$locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
call_hooks('render_location', $locate);
$location = strlen($locate['html']) ? $locate['html'] : render_location_google($locate);
$searchpath = $a->get_baseurl() . "/search?tag=";
$tags = array();
$hashtags = array();
$mentions = array();
/*foreach(explode(',',$item['tag']) as $tag){
$tag = trim($tag);
if ($tag!="") {
$t = bbcode($tag);
$tags[] = $t;
if($t[0] == '#')
$hashtags[] = $t;
elseif($t[0] == '@')
$mentions[] = $t;
}
}*/
$like = x($alike, $item['uri']) ? format_like($alike[$item['uri']], $alike[$item['uri'] . '-l'], 'like', $item['uri']) : '';
$dislike = x($dlike, $item['uri']) ? format_like($dlike[$item['uri']], $dlike[$item['uri'] . '-l'], 'dislike', $item['uri']) : '';
/*
* We should avoid doing this all the time, but it depends on the conversation mode
* And the conv mode may change when we change the conv, or it changes its mode
* Maybe we should establish a way to be notified about conversation changes
*/
$this->check_wall_to_wall();
if ($this->is_wall_to_wall() && $this->get_owner_url() == $this->get_redirect_url()) {
$osparkle = ' sparkle';
}
if ($this->is_toplevel()) {
if ($conv->get_profile_owner() == local_user()) {
$isstarred = $item['starred'] ? "starred" : "unstarred";
$star = array('do' => t("add star"), 'undo' => t("remove star"), 'toggle' => t("toggle star status"), 'classdo' => $item['starred'] ? "hidden" : "", 'classundo' => $item['starred'] ? "" : "hidden", 'starred' => t('starred'));
$r = q("SELECT `ignored` FROM `thread` WHERE `uid` = %d AND `iid` = %d LIMIT 1", intval($item['uid']), intval($item['id']));
if (count($r)) {
$ignore = array('do' => t("ignore thread"), 'undo' => t("unignore thread"), 'toggle' => t("toggle ignore status"), 'classdo' => $r[0]['ignored'] ? "hidden" : "", 'classundo' => $r[0]['ignored'] ? "" : "hidden", 'ignored' => t('ignored'));
}
$tagger = '';
//.........这里部分代码省略.........
示例7: photos_content
//.........这里部分代码省略.........
$album_e = $ph[0]['album'];
$caption_e = $ph[0]['desc'];
$aclselect_e = populate_acl($ph[0]);
}
$edit = replace_macros($edit_tpl, array('$id' => $ph[0]['id'], '$rotatecw' => t('Rotate CW (right)'), '$rotateccw' => t('Rotate CCW (left)'), '$album' => $album_e, '$newalbum' => t('New album name'), '$nickname' => $a->data['user']['nickname'], '$resource_id' => $ph[0]['resource-id'], '$capt_label' => t('Caption'), '$caption' => $caption_e, '$tag_label' => t('Add a Tag'), '$tags' => $link_item['tag'], '$permissions' => t('Permissions'), '$aclselect' => $aclselect_e, '$help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'), '$item_id' => count($linked_items) ? $link_item['id'] : 0, '$submit' => t('Submit'), '$delete' => t('Delete Photo'), '$acl_data' => construct_acl_data($a, $ph[0]), '$group_perms' => t('Show to Groups'), '$contact_perms' => t('Show to Contacts'), '$private' => t('Private photo'), '$public' => t('Public photo'), '$is_private' => $private_post, '$return_path' => $query_str, '$public_link' => $public_post_link));
}
if (count($linked_items)) {
$cmnt_tpl = get_markup_template('comment_item.tpl');
$tpl = get_markup_template('photo_item.tpl');
$return_url = $a->cmd;
$like_tpl = get_markup_template('like_noshare.tpl');
$likebuttons = '';
if ($can_post || can_write_wall($a, $owner_uid)) {
$likebuttons = replace_macros($like_tpl, array('$id' => $link_item['id'], '$likethis' => t("I like this (toggle)"), '$nolike' => feature_enabled(local_user(), 'dislike') ? t("I don't like this (toggle)") : '', '$share' => t('Share'), '$wait' => t('Please wait'), '$return_path' => $a->query_string));
}
$comments = '';
if (!count($r)) {
if ($can_post || can_write_wall($a, $owner_uid)) {
if ($link_item['last-child']) {
$comments .= replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, '$mylink' => $contact['url'], '$mytitle' => t('This is you'), '$myphoto' => $contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), '$sourceapp' => t($a->sourcename), '$ww' => '', '$rand_num' => random_digits(12)));
}
}
}
$alike = array();
$dlike = array();
$like = '';
$dislike = '';
// display comments
if (count($r)) {
foreach ($r as $item) {
like_puller($a, $item, $alike, 'like');
like_puller($a, $item, $dlike, 'dislike');
}
$like = isset($alike[$link_item['id']]) ? format_like($alike[$link_item['id']], $alike[$link_item['id'] . '-l'], 'like', $link_item['id']) : '';
$dislike = isset($dlike[$link_item['id']]) ? format_like($dlike[$link_item['id']], $dlike[$link_item['id'] . '-l'], 'dislike', $link_item['id']) : '';
if ($can_post || can_write_wall($a, $owner_uid)) {
if ($link_item['last-child']) {
$comments .= replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, '$mylink' => $contact['url'], '$mytitle' => t('This is you'), '$myphoto' => $contact['thumb'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), '$sourceapp' => t($a->sourcename), '$ww' => '', '$rand_num' => random_digits(12)));
}
}
foreach ($r as $item) {
$comment = '';
$template = $tpl;
$sparkle = '';
if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) {
continue;
}
$redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'];
if (local_user() && $item['contact-uid'] == local_user() && $item['network'] == 'dfrn' && !$item['self']) {
$profile_url = $redirect_url;
$sparkle = ' sparkle';
} else {
$profile_url = $item['url'];
$sparkle = '';
}
$diff_author = $item['url'] !== $item['author-link'] ? true : false;
$profile_name = strlen($item['author-name']) && $diff_author ? $item['author-name'] : $item['name'];
$profile_avatar = strlen($item['author-avatar']) && $diff_author ? $item['author-avatar'] : $item['thumb'];
$profile_link = $profile_url;
$dropping = $item['contact-id'] == $contact_id || $item['uid'] == local_user();
$drop = array('dropping' => $dropping, 'pagedrop' => false, 'select' => t('Select'), 'delete' => t('Delete'));
if ($a->theme['template_engine'] === 'internal') {
$name_e = template_escape($profile_name);
$title_e = template_escape($item['title']);
$body_e = template_escape(bbcode($item['body']));
} else {
示例8: photos_content
//.........这里部分代码省略.........
} else {
$albums = photos_albums_list($a->data['channel'], $a->data['observer']);
}
$album_e = $ph[0]['album'];
$caption_e = $ph[0]['description'];
$aclselect_e = populate_acl($ph[0]);
$edit = array('edit' => t('Edit photo'), 'id' => $ph[0]['id'], 'rotatecw' => t('Rotate CW (right)'), 'rotateccw' => t('Rotate CCW (left)'), 'albums' => $albums['albums'], 'album' => $album_e, 'newalbum' => t('New album name'), 'nickname' => $a->data['channel']['channel_address'], 'resource_id' => $ph[0]['resource_id'], 'capt_label' => t('Caption'), 'caption' => $caption_e, 'tag_label' => t('Add a Tag'), 'permissions' => t('Permissions'), 'aclselect' => $aclselect_e, 'help_tags' => t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping'), 'item_id' => count($linked_items) ? $link_item['id'] : 0, 'submit' => t('Submit'), 'delete' => t('Delete Photo'));
}
if (count($linked_items)) {
$cmnt_tpl = get_markup_template('comment_item.tpl');
$tpl = get_markup_template('photo_item.tpl');
$return_url = $a->cmd;
$like_tpl = get_markup_template('like_noshare.tpl');
$likebuttons = '';
if ($can_post || $can_comment) {
$likebuttons = replace_macros($like_tpl, array('$id' => $link_item['id'], '$likethis' => t("I like this (toggle)"), '$nolike' => t("I don't like this (toggle)"), '$share' => t('Share'), '$wait' => t('Please wait')));
}
$comments = '';
if (!count($r)) {
if ($can_post || $can_comment) {
$comments .= replace_macros($cmnt_tpl, array('$return_path' => '', '$mode' => 'photos', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, '$mylink' => $observer['xchan_url'], '$mytitle' => t('This is you'), '$myphoto' => $observer['xchan_photo_s'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$preview' => t('Preview'), '$ww' => '', '$feature_encrypt' => false));
}
}
$alike = array();
$dlike = array();
$like = '';
$dislike = '';
// display comments
if ($r) {
foreach ($r as $item) {
like_puller($a, $item, $alike, 'like');
like_puller($a, $item, $dlike, 'dislike');
}
$like = isset($alike[$link_item['id']]) ? format_like($alike[$link_item['id']], $alike[$link_item['id'] . '-l'], 'like', $link_item['id']) : '';
$dislike = isset($dlike[$link_item['id']]) ? format_like($dlike[$link_item['id']], $dlike[$link_item['id'] . '-l'], 'dislike', $link_item['id']) : '';
foreach ($r as $item) {
$comment = '';
$template = $tpl;
$sparkle = '';
if ((activity_match($item['verb'], ACTIVITY_LIKE) || activity_match($item['verb'], ACTIVITY_DISLIKE)) && $item['id'] != $item['parent']) {
continue;
}
$redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'];
$profile_url = zid($item['author']['xchan_url']);
$sparkle = '';
$profile_name = $item['author']['xchan_name'];
$profile_avatar = $item['author']['xchan_photo_m'];
$profile_link = $profile_url;
$drop = '';
if ($observer['xchan_hash'] === $item['author_xchan'] || $observer['xchan_hash'] === $item['owner_xchan']) {
$drop = replace_macros(get_markup_template('photo_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
}
$name_e = $profile_name;
$title_e = $item['title'];
unobscure($item);
$body_e = prepare_text($item['body'], $item['mimetype']);
$comments .= replace_macros($template, array('$id' => $item['item_id'], '$mode' => 'photos', '$profile_url' => $profile_link, '$name' => $name_e, '$thumb' => $profile_avatar, '$sparkle' => $sparkle, '$title' => $title_e, '$body' => $body_e, '$ago' => relative_date($item['created']), '$indent' => $item['parent'] != $item['item_id'] ? ' comment' : '', '$drop' => $drop, '$comment' => $comment));
}
if ($can_post || $can_comment) {
$comments .= replace_macros($cmnt_tpl, array('$return_path' => '', '$jsreload' => $return_url, '$type' => 'wall-comment', '$id' => $link_item['id'], '$parent' => $link_item['id'], '$profile_uid' => $owner_uid, '$mylink' => $observer['xchan_url'], '$mytitle' => t('This is you'), '$myphoto' => $observer['xchan_photo_s'], '$comment' => t('Comment'), '$submit' => t('Submit'), '$ww' => ''));
}
}
$paginate = paginate($a);
}
$album_e = array($album_link, $ph[0]['album']);
$like_e = $like;
示例9: get_template_data
/**
* Get data in a form usable by a conversation template
*
* Returns:
* _ The data requested on success
* _ false on failure
*/
public function get_template_data($alike, $dlike, $thread_level = 1)
{
$t1 = dba_timer();
$result = array();
$a = $this->get_app();
$item = $this->get_data();
$commentww = '';
$sparkle = '';
$buttons = '';
$dropping = false;
$star = false;
$isstarred = "unstarred icon-star-empty";
$indent = '';
$osparkle = '';
$total_children = $this->count_descendants();
$conv = $this->get_conversation();
$observer = $conv->get_observer();
$lock = $item['item_private'] == 1 || $item['uid'] == local_user() && (strlen($item['allow_cid']) || strlen($item['allow_gid']) || strlen($item['deny_cid']) || strlen($item['deny_gid'])) ? t('Private Message') : false;
$shareable = $conv->get_profile_owner() == local_user() && $item['item_private'] != 1 ? true : false;
// allow an exemption for sharing stuff from your private feeds
if ($item['author']['xchan_network'] === 'rss') {
$shareable = true;
}
$mode = $conv->get_mode();
if (local_user() && $observer['xchan_hash'] === $item['author_xchan']) {
$edpost = array($a->get_baseurl($ssl_state) . "/editpost/" . $item['id'], t("Edit"));
} else {
$edpost = false;
}
if ($observer['xchan_hash'] == $this->get_data_value('author_xchan') || $observer['xchan_hash'] == $this->get_data_value('owner_xchan') || $this->get_data_value('uid') == local_user()) {
$dropping = true;
}
if ($dropping) {
$drop = array('dropping' => $dropping, 'delete' => t('Delete'));
}
// FIXME
if ($observer_is_pageowner) {
$multidrop = array('select' => t('Select'));
}
$filer = $conv->get_profile_owner() == local_user() ? t("Save to Folder") : false;
$profile_avatar = $item['author']['xchan_photo_m'];
$profile_link = chanlink_url($item['author']['xchan_url']);
$profile_name = $item['author']['xchan_name'];
$location = format_location($item);
$like_count = x($alike, $item['mid']) ? $alike[$item['mid']] : '';
$like_list = x($alike, $item['mid']) ? $alike[$item['mid'] . '-l'] : '';
if (count($like_list) > MAX_LIKERS) {
$like_list_part = array_slice($like_list, 0, MAX_LIKERS);
array_push($like_list_part, '<a href="#" data-toggle="modal" data-target="#likeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>');
} else {
$like_list_part = '';
}
$like_button_label = tt('Like', 'Likes', $like_count, 'noun');
if (feature_enabled($conv->get_profile_owner(), 'dislike')) {
$dislike_count = x($dlike, $item['mid']) ? $dlike[$item['mid']] : '';
$dislike_list = x($dlike, $item['mid']) ? $dlike[$item['mid'] . '-l'] : '';
$dislike_button_label = tt('Dislike', 'Dislikes', $dislike_count, 'noun');
if (count($dislike_list) > MAX_LIKERS) {
$dislike_list_part = array_slice($dislike_list, 0, MAX_LIKERS);
array_push($dislike_list_part, '<a href="#" data-toggle="modal" data-target="#dislikeModal-' . $this->get_id() . '"><b>' . t('View all') . '</b></a>');
} else {
$dislike_list_part = '';
}
}
$showlike = x($alike, $item['mid']) ? format_like($alike[$item['mid']], $alike[$item['mid'] . '-l'], 'like', $item['mid']) : '';
$showdislike = x($dlike, $item['mid']) && feature_enabled($conv->get_profile_owner(), 'dislike') ? format_like($dlike[$item['mid']], $dlike[$item['mid'] . '-l'], 'dislike', $item['mid']) : '';
/*
* We should avoid doing this all the time, but it depends on the conversation mode
* And the conv mode may change when we change the conv, or it changes its mode
* Maybe we should establish a way to be notified about conversation changes
*/
$this->check_wall_to_wall();
if ($this->is_toplevel()) {
// FIXME check this permission
if ($conv->get_profile_owner() == local_user()) {
// FIXME we don't need all this stuff, some can be done in the template
$star = array('do' => t("Add Star"), 'undo' => t("Remove Star"), 'toggle' => t("Toggle Star Status"), 'classdo' => $item['item_flags'] & ITEM_STARRED ? "hidden" : "", 'classundo' => $item['item_flags'] & ITEM_STARRED ? "" : "hidden", 'isstarred' => $item['item_flags'] & ITEM_STARRED ? "starred icon-star" : "unstarred icon-star-empty", 'starred' => t('starred'));
}
} else {
$indent = 'comment';
}
$verified = $item['item_flags'] & ITEM_VERIFIED ? t('Message is verified') : '';
$unverified = '';
// (($this->is_wall_to_wall() && (! ($item['item_flags'] & ITEM_VERIFIED))) ? t('Message cannot be verified') : '');
// FIXME - check this permission
if ($conv->get_profile_owner() == local_user()) {
$tagger = array('tagit' => t("Add Tag"), 'classtagger' => "");
}
$has_bookmarks = false;
if (is_array($item['term'])) {
foreach ($item['term'] as $t) {
if ($t['type'] == TERM_BOOKMARK) {
$has_bookmarks = true;
//.........这里部分代码省略.........