本文整理汇总了PHP中Comments::allow_modification方法的典型用法代码示例。如果您正苦于以下问题:PHP Comments::allow_modification方法的具体用法?PHP Comments::allow_modification怎么用?PHP Comments::allow_modification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comments
的用法示例。
在下文中一共展示了Comments::allow_modification方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: layout
/**
* list comments as successive reader notes
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// return some formatted text
$text = '<dl class="wiki_comments">';
// build a list of comments
$index = 0;
include_once $context['path_to_root'] . 'comments/comments.php';
while ($item = SQL::fetch($result)) {
// odd or even
$index++;
if ($index % 2) {
$class = 'odd';
} else {
$class = 'even';
}
// get the anchor
$anchor = Anchors::get($item['anchor']);
// include a link to comment permalink
$text .= '<dt class="' . $class . ' details">';
// a link to the user profile
$text .= Users::get_link($item['create_name'], $item['create_address'], $item['create_id']);
$menu = array();
// the creation date
$label = Skin::build_date($item['create_date']);
// flag new comments
if ($item['create_date'] >= $context['fresh']) {
$label .= NEW_FLAG;
}
$menu[] = $label;
// the menu bar for associates and poster
if (Comments::allow_modification($anchor, $item)) {
$menu[] = Skin::build_link(Comments::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic');
$menu[] = Skin::build_link(Comments::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic');
}
$text .= ' - ' . Skin::finalize_list($menu, 'menu');
$text .= '</dt>';
// each comment has an id
$text .= '<dd class="' . $class . '" id="comment_' . $item['id'] . '">';
// the comment itself
$text .= ucfirst(trim($item['description'] . Users::get_signature($item['create_id'])));
// comment has been modified
if ($item['create_name'] && $item['edit_name'] != $item['create_name']) {
$text .= BR . '<span class="details">(' . sprintf(i18n::s('modified by %s'), $item['edit_name']) . ')</span>';
}
// end of this note
$text .= '</dd>';
}
// end of the list
$text .= '</dl>';
// process yacs codes
$text = Codes::beautify($text);
// end of processing
SQL::free($result);
return $text;
}
示例2: elseif
// the title of the page
if (is_object($overlay)) {
$context['page_title'] = $overlay->get_label('delete_title', 'comments');
}
if (!$context['page_title']) {
$context['page_title'] = i18n::s('Delete a comment');
}
// stop crawlers
if (Surfer::is_crawler()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// not found
} elseif (!isset($item['id'])) {
include '../error.php';
// permission denied
} elseif (!Comments::allow_modification($anchor, $item)) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// deletion is confirmed
} elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes') {
// touch the related anchor before actual deletion, since the item has to be accessible at that time
if (is_object($anchor)) {
$anchor->touch('comment:delete', $item['id']);
}
// if no error, back to the anchor or to the index page
if (Comments::delete($item['id'])) {
Comments::clear($item);
if ($render_overlaid && isset($_REQUEST['follow_up']) && $_REQUEST['follow_up'] == 'close') {
echo "deleting done";
finalize_page(true);
} elseif (is_object($anchor)) {
示例3: layout
/**
* list comments as successive notes in a thread
*
* @param resource the SQL result
* @return string the rendered text
**/
function layout($result)
{
global $context;
// we return some text
$output = '';
// empty list
if (!SQL::count($result)) {
return $output;
}
// build a list of comments
$rows = array();
include_once $context['path_to_root'] . 'comments/comments.php';
while ($item = SQL::fetch($result)) {
// get the anchor
$anchor = Anchors::get($item['anchor']);
// get poster information
$poster = array();
if ($item['create_name']) {
if (!($poster = Users::get($item['create_id']))) {
$poster['id'] = 0;
$poster['full_name'] = $item['create_name'];
$poster['email'] = $item['create_address'];
}
} else {
if (!($poster = Users::get($item['edit_id']))) {
$poster['id'] = 0;
$poster['full_name'] = $item['edit_name'];
$poster['email'] = $item['edit_address'];
}
}
// author description
$author = '';
// avatar, but not for notifications
if ($item['type'] != 'notification' && isset($poster['avatar_url']) && $poster['avatar_url']) {
$author .= '<img src="' . $poster['avatar_url'] . '" alt="" title="avatar" class="avatar" />' . BR;
}
// link to poster, if possible
if (isset($poster['id'])) {
$author .= Users::get_link($poster['full_name'], $poster['email'], $poster['id']);
}
// commands to handle this comment
$menu = array();
// get an icon for this comment
$icon = Comments::get_img($item['type']);
// link to comment permalink
$label = Skin::build_link(Comments::get_url($item['id']), $icon, 'basic', i18n::s('View this comment')) . ' ';
// the creation date
if ($item['create_date']) {
$label .= Skin::build_date($item['create_date'], 'with_hour');
} else {
$label .= Skin::build_date($item['edit_date'], 'with_hour');
}
// flag new comments
if ($item['create_date'] >= $context['fresh']) {
$label .= NEW_FLAG;
}
$menu[] = $label;
// an approval -- can be modified, but not deleted
if ($item['type'] == 'approval') {
// additional commands for associates and poster and editor
if ($anchor->is_owned()) {
Skin::define_img('COMMENTS_EDIT_IMG', 'comments/edit.gif');
$menu[] = Skin::build_link(Comments::get_url($item['id'], 'edit'), COMMENTS_EDIT_IMG . i18n::s('Edit'), 'basic');
}
// an automatic notification -- can be deleted, but not modified
} elseif ($item['type'] == 'notification') {
// additional commands for associates and poster and editor
if ($anchor->is_owned()) {
Skin::define_img('COMMENTS_DELETE_IMG', 'comments/delete.gif');
$menu[] = Skin::build_link(Comments::get_url($item['id'], 'delete'), COMMENTS_DELETE_IMG . i18n::s('Delete'), 'basic');
}
// regular case
} else {
// additional commands for associates and poster and editor
if (Comments::allow_modification($anchor, $item)) {
Skin::define_img('COMMENTS_EDIT_IMG', 'comments/edit.gif');
$menu[] = Skin::build_link(Comments::get_url($item['id'], 'edit'), COMMENTS_EDIT_IMG . i18n::s('Edit'), 'basic');
Skin::define_img('COMMENTS_DELETE_IMG', 'comments/delete.gif');
$menu[] = Skin::build_link(Comments::get_url($item['id'], 'delete'), COMMENTS_DELETE_IMG . i18n::s('Delete'), 'basic');
}
}
// comment main text
$text = '';
// state clearly that this is an approval
if ($item['type'] == 'approval' && isset($poster['id'])) {
$text .= '<p>' . sprintf(i18n::s('%s has provided his approval'), Users::get_link($poster['full_name'], $poster['email'], $poster['id'])) . '</p>';
}
// display comment main text
$text .= $item['description'];
// display signature, but not for notifications
if ($item['type'] != 'notification') {
$text .= Users::get_signature($item['create_id']);
}
// format and display
//.........这里部分代码省略.........
示例4: layout
/**
* list comments
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// sanity check
if (!isset($this->layout_variant)) {
$this->layout_variant = 'full';
}
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
while ($item = SQL::fetch($result)) {
// get the anchor
$anchor = Anchors::get($item['anchor']);
// initialize variables
$prefix = $suffix = '';
// there is no zoom page for comments
$label = '_';
// the icon is a link to comment permalink
$suffix .= Skin::build_link(Comments::get_url($item['id']), Comments::get_img($item['type']), 'basic', i18n::s('View this comment'));
// a link to the user profile
if ($item['create_name']) {
$suffix .= ' ' . Users::get_link($item['create_name'], $item['create_address'], $item['create_id']);
} else {
$suffix .= ' ' . Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']);
}
$menu = array();
// the edition date
if ($item['create_date']) {
$menu[] = Skin::build_date($item['create_date']);
} else {
$menu[] = Skin::build_date($item['edit_date']);
}
// the menu bar for associates, editors and poster
if (Comments::allow_modification($anchor, $item)) {
$menu[] = Skin::build_link(Comments::get_url($item['id'], 'edit'), i18n::s('edit'), 'span');
$menu[] = Skin::build_link(Comments::get_url($item['id'], 'delete'), i18n::s('delete'), 'span');
}
if ($menu) {
$suffix .= ' -' . Skin::finalize_list($menu, 'menu');
}
// new line
$suffix .= BR;
// description
if ($description = ucfirst(trim(Codes::beautify($item['description'] . Users::get_signature($item['create_id']))))) {
$suffix .= ' ' . $description;
}
// url to view the comment
$url = Comments::get_url($item['id']);
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'comment', NULL);
}
// end of processing
SQL::free($result);
return $items;
}
示例5: strip_tags
// fight hackers
$id = strip_tags($id);
$target_anchor = strip_tags($target_anchor);
// get the item from the database
$item = Comments::get($id);
// get the related anchor, if any
$anchor = NULL;
if (isset($item['anchor']) && $item['anchor']) {
$anchor = Anchors::get($item['anchor']);
} elseif ($target_anchor) {
$anchor = Anchors::get($target_anchor);
}
// associates and authenticated editors can modify any comment
if ($action != 'edit' && Comments::allow_creation($anchor)) {
$permitted = TRUE;
} elseif ($action == 'edit' && Comments::allow_modification($anchor, $item)) {
$permitted = TRUE;
} else {
$permitted = FALSE;
}
// do not always show the edition form
$with_form = FALSE;
// load the skin, maybe with a variant
load_skin('comments', $anchor);
// clear the tab we are in, if any
if (is_object($anchor)) {
$context['current_focus'] = $anchor->get_focus();
}
// the path to this page
if (is_object($anchor) && $anchor->is_viewable() && !$render_overlaid) {
$context['path_bar'] = $anchor->get_path_bar();