本文整理汇总了PHP中Comments::allow_creation方法的典型用法代码示例。如果您正苦于以下问题:PHP Comments::allow_creation方法的具体用法?PHP Comments::allow_creation怎么用?PHP Comments::allow_creation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comments
的用法示例。
在下文中一共展示了Comments::allow_creation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: layout
//.........这里部分代码省略.........
$details[] = sprintf(i18n::s('with %s'), $friends);
}
// people details
if ($details) {
$text .= '<p class="details">' . join(', ', $details) . "</p>\n";
}
// the introductory text
$introduction = '';
if (is_object($overlay)) {
$introduction = $overlay->get_text('introduction', $item);
} elseif ($item['introduction']) {
$introduction = $item['introduction'];
}
if ($introduction) {
$text .= '<div style="margin: 1em 0;">' . Codes::beautify_introduction($introduction) . '</div>';
}
// insert overlay data, if any
if (is_object($overlay)) {
$text .= $overlay->get_text('list', $item);
}
// info on related comments
if (($count = Comments::count_for_anchor('article:' . $item['id'])) > 1) {
$text .= '<div style="margin-top: 1em;"><p class="details">' . sprintf(i18n::s('%d contributions, including:'), $count) . '</p></div>';
}
// avoid first file if mentioned in last contribution
$file_offset = 0;
// get last contribution for this page
if ($comment = Comments::get_newest_for_anchor('article:' . $item['id'])) {
if (preg_match('/\\[(download|file)=/', $comment['description'])) {
$file_offset++;
}
// bars around the last contribution
$bottom_menu = array();
// last contributor
$contributor = Users::get_link($comment['create_name'], $comment['create_address'], $comment['create_id']);
$flag = '';
if ($comment['create_date'] >= $context['fresh']) {
$flag = NEW_FLAG;
} elseif ($comment['edit_date'] >= $context['fresh']) {
$flag = UPDATED_FLAG;
}
$bottom_menu[] = sprintf(i18n::s('By %s'), $contributor) . ' ' . Skin::build_date($comment['create_date']) . $flag;
// offer to reply
if (Comments::allow_creation($item, $anchor)) {
$link = Comments::get_url($comment['id'], 'reply');
$bottom_menu[] = Skin::build_link($link, i18n::s('Reply'), 'basic');
}
// gather pieces
$pieces = array();
// last contribution, and user signature
$pieces[] = ucfirst(trim($comment['description'])) . Users::get_signature($comment['create_id']);
// bottom
if ($bottom_menu) {
$pieces[] = '<div style="margin-top: 1em;">' . ucfirst(trim(Skin::finalize_list($bottom_menu, 'menu'))) . '</div>';
}
// put all pieces together
$text .= '<div class="last_comment">' . "\n" . join("\n", $pieces) . '</div>' . "\n";
}
// list more recent files
if ($items = Files::list_by_date_for_anchor('article:' . $item['id'], $file_offset, 3, 'dates')) {
// more files than listed
$more = '';
if (($count = Files::count_for_anchor('article:' . $item['id'])) > 3) {
$more = '<span class="details">' . sprintf(i18n::s('%d files, including:'), $count) . '</span>';
}
if (is_array($items)) {
$items = Skin::build_list($items, 'compact');
}
$text .= '<div style="margin: 1em 0;">' . $more . $items . '</div>';
}
// display all tags
if ($item['tags']) {
$text .= ' <p class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>';
}
// navigation links
$menu = array();
// permalink
$menu[] = Skin::build_link($url, i18n::s('View the page'), 'span');
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$menu[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// the main anchor link
if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) {
$menu[] = Skin::build_link($anchor->get_url(), sprintf(i18n::s('in %s'), ucfirst($anchor->get_title())), 'span', i18n::s('View the section'));
}
// actually insert details
$text .= Skin::finalize_list($menu, 'menu_bar');
// bottom of the box
$text .= '</div>';
}
// close the list of articles
$text .= '</div>';
// beautify everything at once
$text = Codes::beautify($text);
// end of processing
SQL::free($result);
// done
return $text;
}
示例2: layout
//.........这里部分代码省略.........
} else {
$title = Codes::beautify_title($item['title']);
}
// one row per article
$text .= '<tr class="' . ($odd ? 'odd' : 'even') . '"><td>';
$odd = !$odd;
// signal articles to be published
if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
$text .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$text .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$text .= RESTRICTED_FLAG;
}
// use the title as a link to the page
$text .= Skin::build_link($url, '<strong>' . $title . '</strong>', 'basic');
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$text .= ' ' . LOCKED_FLAG;
}
// flag articles updated recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$text .= ' ' . EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$text .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$text .= ' ' . UPDATED_FLAG;
}
// add details, if any
$details = array();
// poster name
if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
if ($item['create_name']) {
$details[] = sprintf(i18n::s('posted by %s %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Skin::build_date($item['create_date']));
}
}
// last update
$details[] = sprintf(i18n::s('Updated %s'), Skin::build_date($item['edit_date']));
// add details to the title
if (count($details)) {
$text .= '<p class="details" style="margin: 3px 0">' . join(', ', $details) . '</p>';
}
// display all tags
if ($item['tags']) {
$text .= '<p class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>';
}
// next cell for the content
$text .= '</td><td width="70%">';
// the content to be displayed
$content = '';
// rating
if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
$content .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
}
// the introductory text
if (is_object($overlay)) {
$content .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
} else {
$content .= Codes::beautify_introduction($item['introduction']);
}
// insert overlay data, if any
if (is_object($overlay)) {
$content .= $overlay->get_text('list', $item);
}
// the description
$content .= Skin::build_block($item['description'], 'description', '', $item['options']);
// attachment details
$details = array();
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'])) {
Skin::define_img('FILES_LIST_IMG', 'files/list.gif');
$details[] = Skin::build_link($url . '#_attachments', FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count), 'span');
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
Skin::define_img('LINKS_LIST_IMG', 'links/list.gif');
$details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// count replies
if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
$details[] = Skin::build_link($url . '#_discussion', sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span');
}
// the command to reply
if (Comments::allow_creation($item, $anchor)) {
Skin::define_img('COMMENTS_ADD_IMG', 'comments/add.gif');
$details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), COMMENTS_ADD_IMG . i18n::s('Post a comment'), 'span');
}
// describe attachments
$content .= Skin::finalize_list($details, 'menu_bar');
// end the row
$text .= $content . '</td></tr>';
}
// end of processing
SQL::free($result);
// return the table
$text .= Skin::table_suffix();
return $text;
}
示例3: layout_newest
//.........这里部分代码省略.........
$text .= $overlay->get_text('view', $item);
}
// the beautified description, which is the actual page body
if ($item['description']) {
// use adequate label
if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
$text .= Skin::build_block($label, 'title');
}
$text .= Skin::build_block($item['description'], 'description', '', $item['options']);
}
//
// list related files
//
// if this surfer is an editor of this article, show hidden files as well
if (Articles::is_assigned($item['id']) || is_object($anchor) && $anchor->is_assigned()) {
Surfer::empower();
}
// build a complete box
$box['bar'] = array();
$box['text'] = '';
// count the number of files in this article
if ($count = Files::count_for_anchor('article:' . $item['id'])) {
if ($count > 20) {
$box['bar'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count));
}
// list files by date (default) or by title (option files_by_title)
if (Articles::has_option('files_by', $anchor, $item) == 'title') {
$items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'article:' . $item['id']);
} else {
$items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'article:' . $item['id']);
}
if (is_array($items)) {
$box['text'] .= Skin::build_list($items, 'decorated');
}
// navigation commands for files
$prefix = Articles::get_url($item['id'], 'navigate', 'files');
$box['bar'] += Skin::navigate($url, $prefix, $count, FILES_PER_PAGE, 0);
// the command to post a new file, if allowed
if (Files::allow_creation($item, $anchor, 'article')) {
$link = 'files/edit.php?anchor=' . urlencode('article:' . $item['id']);
$box['bar'] += array($link => i18n::s('Add a file'));
}
if (is_array($box['bar'])) {
$box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
}
}
// actually render the html for this box
if ($box['text']) {
$text .= Skin::build_box(i18n::s('Files'), $box['text'], 'header1', 'files');
}
//
// bottom page menu
//
// discuss this page, if the index page can be commented, and comments are accepted at the article level
if (Comments::allow_creation($item, $anchor)) {
$this->menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Post a comment'), 'span');
}
// info on related comments
if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
$this->menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span');
}
// new links are accepted at the index page and at the article level
if (Links::allow_trackback()) {
$this->menu[] = Skin::build_link('links/trackback.php?anchor=' . urlencode('article:' . $item['id']), i18n::s('Reference this page'), 'span');
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'])) {
$this->menu[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'span');
}
// new files are accepted at the index page and at the article level
if (is_object($anchor) && $anchor->has_option('with_files') && !($anchor->has_option('no_files') || preg_match('/\\bno_files\\b/i', $item['options']))) {
// add a file
if (Files::allow_creation($item, $anchor, 'article')) {
if ($context['with_friendly_urls'] == 'Y') {
$link = 'files/edit.php/article/' . $item['id'];
} else {
$link = 'files/edit.php?anchor=' . urlencode('article:' . $item['id']);
}
$this->menu[] = Skin::build_link($link, i18n::s('Add a file'), 'span');
}
}
// modify this page
if (Surfer::is_empowered()) {
$this->menu[] = Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('Edit'), 'span');
}
// view permalink
if (Surfer::is_empowered()) {
$this->menu[] = Skin::build_link($url, i18n::s('Permalink'), 'span');
}
// insert overlay data, if any
if (is_object($overlay)) {
$text .= $overlay->get_text('trailer', $item);
}
// add trailer information from this item, if any
if (isset($item['trailer']) && trim($item['trailer'])) {
$text .= Codes::beautify($item['trailer']);
}
// returned the formatted content
return $text;
}
示例4: touch
/**
* remember the last action for this section
*
* @see articles/article.php
* @see shared/anchor.php
*
* @param string the description of the last action
* @param string the id of the item related to this update
* @param boolean TRUE to not change the edit date of this anchor, default is FALSE
*/
function touch($action, $origin = NULL, $silently = FALSE)
{
global $context;
// we make extensive use of comments below
include_once $context['path_to_root'] . 'comments/comments.php';
// don't go further on import
if (preg_match('/import$/i', $action)) {
return;
}
// no section bound
if (!isset($this->item['id'])) {
return;
}
// delegate to overlay
if (is_object($this->overlay) && $this->overlay->touch($action, $origin, $silently) === false) {
return;
// stop on false
}
// sanity check
if (!$origin) {
logger::remember('sections/section.php: unexpected NULL origin at touch()');
return;
}
// components of the query
$query = array();
// a new page has been added to the section
if ($action == 'article:publish' || $action == 'article:submit') {
// limit the number of items attached to this section
if (isset($this->item['maximum_items']) && $this->item['maximum_items'] > 10) {
Articles::purge_for_anchor('section:' . $this->item['id'], $this->item['maximum_items']);
}
// a new comment has been posted
} elseif ($action == 'comment:create') {
// purge oldest comments
Comments::purge_for_anchor('section:' . $this->item['id']);
// file upload
} elseif ($action == 'file:create' || $action == 'file:upload') {
// actually, several files have been added
$label = '';
if (!$origin) {
$fields = array();
$fields['anchor'] = 'section:' . $this->item['id'];
$fields['description'] = i18n::s('Several files have been added');
$fields['type'] = 'notification';
Comments::post($fields);
// one file has been added
} elseif (!Codes::check_embedded($this->item['description'], 'embed', $origin) && ($item = Files::get($origin, TRUE))) {
// this file is eligible for being embedded in the page
if (isset($item['file_name']) && Files::is_embeddable($item['file_name'])) {
// the overlay may prevent embedding
if (is_object($this->overlay) && !$this->overlay->should_embed_files()) {
} else {
$label = '[embed=' . $origin . ']';
}
// else add a comment to take note of the upload
} elseif (Comments::allow_creation($this->item, null, 'section')) {
$fields = array();
$fields['anchor'] = 'section:' . $this->item['id'];
if ($action == 'file:create') {
$fields['description'] = '[file=' . $item['id'] . ',' . $item['file_name'] . ']';
} else {
$fields['description'] = '[download=' . $item['id'] . ',' . $item['file_name'] . ']';
}
Comments::post($fields);
}
}
// include flash videos in a regular page
if ($label) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' ' . $label) . "'";
}
// suppress references to a deleted file
} elseif ($action == 'file:delete') {
// suppress reference in main description field
$text = Codes::delete_embedded($this->item['description'], 'download', $origin);
$text = Codes::delete_embedded($text, 'embed', $origin);
$text = Codes::delete_embedded($text, 'file', $origin);
// save changes
$query[] = "description = '" . SQL::escape($text) . "'";
// append a reference to a new image to the description
} elseif ($action == 'image:create') {
if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
// the overlay may prevent embedding
if (is_object($this->overlay) && !$this->overlay->should_embed_files()) {
} else {
// list has already started
if (preg_match('/\\[image=[^\\]]+?\\]\\s*$/', $this->item['description'])) {
$query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
} else {
$query[] = "description = '" . SQL::escape($this->item['description'] . "\n\n" . '[image=' . $origin . ']') . "'";
}
//.........这里部分代码省略.........
示例5: urlencode
if ($this_cat->allow_creation()) {
Skin::define_img('CATEGORIES_ADD_IMG', 'categories/add.gif');
$context['page_tools'][] = Skin::build_link('categories/edit.php?anchor=' . urlencode('category:' . $item['id']), CATEGORIES_ADD_IMG . i18n::s('Add a category'), 'basic');
}
// post an image, if upload is allowed
if (Images::allow_creation($item, $anchor, 'category')) {
Skin::define_img('IMAGES_ADD_IMG', 'images/add.gif');
$context['page_tools'][] = Skin::build_link('images/edit.php?anchor=' . urlencode('category:' . $item['id']), IMAGES_ADD_IMG . i18n::s('Add an image'), 'basic', i18n::s('You can upload a camera shot, a drawing, or another image file.'));
}
// add a file, if upload is allowed
if (Files::allow_creation($item, $anchor, 'category')) {
Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif');
$context['page_tools'][] = Skin::build_link('files/edit.php?anchor=' . urlencode('category:' . $item['id']), FILES_UPLOAD_IMG . i18n::s('Add a file'), 'basic', i18n::s('Attach related files.'));
}
// comment this page if anchor does not prevent it
if (Comments::allow_creation($item, $anchor, 'category')) {
Skin::define_img('COMMENTS_ADD_IMG', 'comments/add.gif');
$context['page_tools'][] = Skin::build_link(Comments::get_url('category:' . $item['id'], 'comment'), COMMENTS_ADD_IMG . i18n::s('Post a comment'), 'basic', i18n::s('Express yourself, and say what you think.'));
}
// add a link
if (Links::allow_creation($item, $anchor, 'category')) {
Skin::define_img('LINKS_ADD_IMG', 'links/add.gif');
$context['page_tools'][] = Skin::build_link('links/edit.php?anchor=' . urlencode('category:' . $item['id']), LINKS_ADD_IMG . i18n::s('Add a link'), 'basic', i18n::s('Contribute to the web and link to relevant pages.'));
}
// modify this item
Skin::define_img('CATEGORIES_EDIT_IMG', 'categories/edit.gif');
$context['page_tools'][] = Skin::build_link(Categories::get_url($item['id'], 'edit'), CATEGORIES_EDIT_IMG . i18n::s('Edit this category'), 'basic', i18n::s('Press [e] to edit'), FALSE, 'e');
// delete this item
Skin::define_img('CATEGORIES_DELETE_IMG', 'categories/delete.gif');
$context['page_tools'][] = Skin::build_link(Categories::get_url($item['id'], 'delete'), CATEGORIES_DELETE_IMG . i18n::s('Delete this category'));
// manage persons assigned to this category
示例6: layout
/**
* list articles
*
* @param resource the SQL result
* @return a string to be displayed
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// no hovering label
$href_title = '';
// we build an array for the skin::build_tabs() function
$panels = array();
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// panel content
$text = '';
// insert anchor prefix
if (is_object($anchor)) {
$text .= $anchor->get_prefix();
}
// the introduction text, if any
if (is_object($overlay)) {
$text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
} elseif (isset($item['introduction']) && trim($item['introduction'])) {
$text .= Skin::build_block($item['introduction'], 'introduction');
}
// get text related to the overlay, if any
if (is_object($overlay)) {
$text .= $overlay->get_text('view', $item);
}
// filter description, if necessary
if (is_object($overlay)) {
$description = $overlay->get_text('description', $item);
} else {
$description = $item['description'];
}
// the beautified description, which is the actual page body
if ($description) {
// use adequate label
if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
$text .= Skin::build_block($label, 'title');
}
// beautify the target page
$text .= Skin::build_block($description, 'description', '', $item['options']);
}
// list files only to people able to change the page
if (Articles::allow_modification($item, $anchor)) {
$embedded = NULL;
} else {
$embedded = Codes::list_embedded($item['description']);
}
// build a complete box
$box = array('bar' => array(), 'text' => '');
// count the number of files in this article
if ($count = Files::count_for_anchor('article:' . $item['id'], FALSE, $embedded)) {
if ($count > 20) {
$box['bar'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count));
}
// list files by date (default) or by title (option files_by_title)
$offset = ($zoom_index - 1) * FILES_PER_PAGE;
if (Articles::has_option('files_by', $anchor, $item) == 'title') {
$items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, 300, 'article:' . $item['id'], $embedded);
} else {
$items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, 300, 'article:' . $item['id'], $embedded);
}
// actually render the html
if (is_array($items)) {
$box['text'] .= Skin::build_list($items, 'decorated');
} elseif (is_string($items)) {
$box['text'] .= $items;
}
// the command to post a new file
if (Files::allow_creation($item, $anchor, 'article')) {
Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif');
$box['bar'] += array('files/edit.php?anchor=' . urlencode('article:' . $item['id']) => FILES_UPLOAD_IMG . i18n::s('Add a file'));
}
}
// some files have been attached to this page
if ($page == 1 && $count > 1) {
// the command to download all files
$link = 'files/fetch_all.php?anchor=' . urlencode('article:' . $item['id']);
if ($count > 20) {
$label = i18n::s('Zip 20 first files');
} else {
$label = i18n::s('Zip all files');
}
$box['bar'] += array($link => $label);
//.........这里部分代码省略.........
示例7: layout
//.........这里部分代码省略.........
// flag articles updated recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$box['title'] .= EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$box['title'] .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$box['title'] .= UPDATED_FLAG;
}
// what's the date of publication?
if (isset($item['publish_date']) && $item['publish_date'] > NULL_DATE) {
$box['date'] .= Skin::build_date($item['publish_date'], 'publishing');
}
// the icon to put aside - never use anchor images
if ($item['icon_url']) {
$box['content'] .= '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $item['icon_url'] . '" class="left_image" alt="" /></a>';
}
// details
$details = array();
// rating
if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
$details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
}
// show details
if (count($details)) {
$box['content'] .= '<p class="details">' . implode(' ~ ', $details) . '</p>' . "\n";
}
// list categories by title, if any
if ($items = Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
$tags = array();
foreach ($items as $id => $attributes) {
// add background color to distinguish this category against others
if (isset($attributes['background_color']) && $attributes['background_color']) {
$attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>';
}
$tags[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
}
$box['content'] .= '<p class="tags">' . implode(' ', $tags) . '</p>';
}
// the introduction text, if any
if (is_object($overlay)) {
$box['content'] .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
} else {
$box['content'] .= Skin::build_block($item['introduction'], 'introduction');
}
// insert overlay data, if any
if (is_object($overlay)) {
$box['content'] .= $overlay->get_text('list', $item);
}
// the description
$box['content'] .= Skin::build_block($item['description'], 'description', '', $item['options']);
// a compact list of attached files
if ($count = Files::count_for_anchor('article:' . $item['id'])) {
// list files by date (default) or by title (option files_by_title)
if (Articles::has_option('files_by', $anchor, $item) == 'title') {
$items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'compact');
} else {
$items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'compact');
}
if (is_array($items)) {
$items = Skin::build_list($items, 'compact');
}
if ($items) {
$box['content'] .= Skin::build_box(i18n::s('Files'), $items, 'header2');
}
}
// build a menu
$menu = array();
// read the article
$menu[] = Skin::build_link($url, i18n::s('Permalink'), 'span');
// info on related files
if ($count) {
$menu[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'span');
}
// info on related comments
if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
$menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span');
}
// comment
if (Comments::allow_creation($item, $anchor)) {
$menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'span');
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$menu[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'span');
}
// trackback
if (Links::allow_trackback()) {
$menu[] = Skin::build_link('links/trackback.php?anchor=' . urlencode('article:' . $item['id']), i18n::s('Reference this page'), 'span');
}
// a menu bar
if (count($menu)) {
$box['content'] .= '<div class="menu_bar" style="clear: left;">' . MENU_PREFIX . implode(MENU_SEPARATOR, $menu) . MENU_SUFFIX . "</div>\n";
}
// build a simple box for this post
$text .= '<div class="post">' . '<div class="date">' . $box['date'] . '</div>' . '<h2><span>' . $box['title'] . '</span></h2>' . '<div class="content">' . $box['content'] . '</div>' . '</div>';
}
// end of processing
SQL::free($result);
return $text;
}
示例8: layout
//.........这里部分代码省略.........
$suffix .= ' ' . UPDATED_FLAG;
}
// add details
$details = array();
// the author
if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
if ($item['edit_name'] == $item['create_name']) {
$details[] = sprintf(i18n::s('by %s'), ucfirst($item['create_name']));
} else {
$details[] = sprintf(i18n::s('by %s, %s'), ucfirst($item['create_name']), ucfirst($item['edit_name']));
}
}
// the publish date
$details[] = Skin::build_date($item['publish_date']);
// rating
$rating_label = '';
if ($item['rating_count']) {
$rating_label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ' . sprintf(i18n::ns('%d rating', '%d ratings', $item['rating_count']), $item['rating_count']) . ' ';
}
// add a link to let surfer rate this item
if (is_object($anchor) && !$anchor->has_option('without_rating')) {
if (!$item['rating_count']) {
$rating_label .= i18n::s('Rate this page');
}
$rating_label = Skin::build_link(Articles::get_url($item['id'], 'like'), $rating_label, 'basic', i18n::s('Rate this page'));
}
// display current rating, and allow for rating
$details[] = $rating_label;
// details
if (count($details)) {
$content .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>';
}
// the full introductory text
if ($item['introduction']) {
$content .= Codes::beautify($item['introduction'], $item['options']);
} elseif (!is_object($overlay)) {
include_once $context['path_to_root'] . 'articles/article.php';
$article = new Article();
$article->load_by_content($item);
$content .= $article->get_teaser('teaser');
}
// insert overlay data, if any
if (is_object($overlay)) {
$content .= $overlay->get_text('list', $item);
}
// an array of links
$menu = array();
// rate the article
$menu = array_merge($menu, array(Articles::get_url($item['id'], 'like') => i18n::s('Rate this page')));
// read the article
$menu = array_merge($menu, array($url => i18n::s('Read more')));
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic');
}
// info on related comments
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$link = Comments::get_url('article:' . $item['id'], 'list');
$menu = array_merge($menu, array($link => sprintf(i18n::ns('%d comment', '%d comments', $count), $count)));
}
// discuss
if (Comments::allow_creation($item, $anchor)) {
$menu = array_merge($menu, array(Comments::get_url('article:' . $item['id'], 'comment') => i18n::s('Discuss')));
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$menu = array_merge($menu, array($url . '#_attachments' => sprintf(i18n::ns('%d link', '%d links', $count), $count)));
}
// trackback
if (Links::allow_trackback()) {
$menu = array_merge($menu, array('links/trackback.php?anchor=' . urlencode('article:' . $item['id']) => i18n::s('Reference this page')));
}
// link to the anchor page
if (is_object($anchor)) {
$menu = array_merge($menu, array($anchor->get_url() => $anchor->get_title()));
}
// list up to three categories by title, if any
if ($items = Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 3, 'raw')) {
foreach ($items as $id => $attributes) {
$menu = array_merge($menu, array(Categories::get_permalink($attributes) => $attributes['title']));
}
}
// append a menu
$content .= Skin::build_list($menu, 'menu_bar');
// insert a complete box
$text .= Skin::build_box($icon . $prefix . Codes::beautify_title($item['title']) . $suffix, $content, 'header1', 'article_' . $item['id']);
// section closing
if ($item_count == 1) {
$text .= '</div>' . "\n";
}
}
// end of processing
SQL::free($result);
// add links to archives
$anchor = Categories::get(i18n::c('monthly'));
if (isset($anchor['id']) && ($items = Categories::list_by_date_for_anchor('category:' . $anchor['id'], 0, COMPACT_LIST_SIZE, 'compact'))) {
$text .= Skin::build_box(i18n::s('Previous pages'), Skin::build_list($items, 'menu_bar'));
}
return $text;
}
示例9: array
$box['bar'] += array('_count' => $count . ' ' . strtolower($label));
}
// navigation commands for comments
$prefix = Comments::get_url($anchor->get_reference(), 'navigate');
$box['bar'] = array_merge($box['bar'], Skin::navigate($anchor->get_url('comments'), $prefix, $count, $items_per_page, $page, FALSE));
// list comments by date
$items = Comments::list_by_date_for_anchor($anchor->get_reference(), $offset, $items_per_page, $layout, TRUE);
// actually render the html
if (is_array($items)) {
$box['text'] .= Skin::build_list($items, 'rows');
} elseif (is_string($items)) {
$box['text'] .= $items;
}
}
// the command to post a new comment, if this is allowed
if (Comments::allow_creation($anchor)) {
Skin::define_img('COMMENTS_ADD_IMG', 'comments/add.gif');
$label = '';
if (is_object($anchor->overlay)) {
$label = $anchor->overlay->get_label('new_command', 'comments');
}
if (!$label) {
$label = i18n::s('Add a comment');
}
$box['bar'] = array_merge($box['bar'], array(Comments::get_url($anchor->get_reference(), 'comment') => COMMENTS_ADD_IMG . $label));
}
// show commands
if (@count($box['bar'])) {
// append the menu bar at the end
if (strlen($box['text']) > 10 && $count) {
$box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
示例10: function
}
// the submit button
$menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's', 'submit');
// go to smileys
// $menu[] = Skin::build_link('smileys/', i18n::s('Smileys'), 'open');
// display all commands
$context['text'] .= Skin::finalize_list($menu, 'menu_bar');
// end the form
$context['text'] .= '</form>' . "\n";
}
// end of the wrapper
$context['text'] .= '</div>' . "\n";
// the AJAX part
$js_script = 'var Comments = {' . "\n" . "\n" . ' url: "' . $context['url_to_home'] . $context['url_to_root'] . Comments::get_url($item['id'], 'thread') . '",' . "\n" . ' timestamp: 0,' . "\n" . "\n" . ' initialize: function() { },' . "\n" . "\n" . ' contribute: function() {' . "\n" . ' Yacs.startWorking();' . "\n" . ' $("#upload_frame").load(Comments.contributed);' . "\n" . ' return true;' . "\n" . ' },' . "\n" . "\n" . ' contributed: function() {' . "\n" . ' $("#upload_frame").unbind("load");' . "\n" . ' $("#comment_upload").slideUp(600);' . "\n" . ' $("#upload_option").slideUp();' . "\n" . ' $("#upload").replaceWith(\'<input type="file" id="upload" name="upload" size="30" />\');' . "\n" . ' $("#description").val("").trigger("change").focus();' . "\n" . ' setTimeout(function() {Comments.subscribe(); Yacs.stopWorking();}, 500);' . "\n" . ' if((typeof OpenTok == "object") && OpenTok.session)' . "\n" . ' OpenTok.signal();' . "\n" . ' },' . "\n" . "\n" . ' keypress: function(event) {' . "\n" . ' if(event.which == 13) {' . "\n" . ' $("#submit").trigger("click");' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' },' . "\n" . "\n" . ' showMore: function() {' . "\n" . ' var options = {};' . "\n" . ' var newHeight = $("#thread_text_panel").clientHeight + 200;' . "\n" . ' options.height = newHeight + "px";' . "\n" . ' options.maxHeight = newHeight + "px";' . "\n" . ' $("#thread_text_panel").css(options);' . "\n" . ' },' . "\n" . "\n" . ' subscribe: function() {' . "\n" . ' $.ajax(Comments.url, {' . "\n" . ' type: "get",' . "\n" . ' dataType: "json",' . "\n" . ' data: { "timestamp" : Comments.timestamp },' . "\n" . ' success: Comments.updateOnSuccess' . "\n" . ' });' . "\n" . "\n" . ' },' . "\n" . "\n" . ' subscribeToExtraUpdates: function() {' . "\n" . ' $.ajax("' . $context['url_to_home'] . $context['url_to_root'] . Users::get_url($item['id'], 'visit') . '", {' . "\n" . ' type: "get",' . "\n" . ' dataType: "html",' . "\n" . ' success: function(data) { $("#thread_roster_panel").html(data); }' . "\n" . ' });' . "\n" . "\n" . ' $.ajax("' . $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'thread') . '", {' . "\n" . ' type: "get",' . "\n" . ' dataType: "html",' . "\n" . ' success: function(data) { $("#thread_files_panel").html(data); }' . "\n" . ' });' . "\n" . "\n" . ' },' . "\n" . "\n" . ' updateOnSuccess: function(response) {' . "\n" . ' if(!response) return;' . "\n" . ' if(response["status"] != "started")' . "\n" . ' window.location.reload(true);' . "\n" . ' $("#thread_text_panel").html("<div>" + response["items"] + "</div>");' . "\n" . ' var div = $("#thread_text_panel")[0];' . "\n" . ' var scrollHeight = Math.max(div.scrollHeight, div.clientHeight);' . "\n" . ' div.scrollTop = scrollHeight - div.clientHeight;' . "\n" . ' if(typeof Comments.windowOriginalTitle != "string")' . "\n" . ' Comments.windowOriginalTitle = document.title;' . "\n" . ' document.title = "[" + response["name"] + "] " + Comments.windowOriginalTitle;' . "\n" . ' Comments.timestamp = response["timestamp"];' . "\n" . ' }' . "\n" . "\n" . '}' . "\n" . "\n" . '// wait for new comments and for other updates' . "\n" . 'Comments.subscribeTimer = setInterval("Comments.subscribe()", 5000);' . "\n" . 'Comments.subscribeTimer = setInterval("Comments.subscribeToExtraUpdates()", 59999);' . "\n" . "\n" . '// load past contributions asynchronously' . "\n" . '$(function() {' . 'Comments.subscribe();' . 'location.hash="#thread_text_panel";' . '$("#description").tipsy({gravity: "s", fade: true, title: function () {return "' . i18n::s('Contribute here') . '";}, trigger: "manual"});' . '$("#description").tipsy("show");' . 'setTimeout("$(\'#description\').tipsy(\'hide\');", 10000);' . '$("textarea#description").autogrow();' . '});' . "\n";
// only authenticated surfers can contribute
if (Surfer::is_logged() && Comments::allow_creation($item, $anchor)) {
$js_script .= '$(function() {' . '$("#description").focus();' . '});' . "\n" . '$(\'#description\').keypress( Comments.keypress );' . "\n";
}
break;
Page::insert_script($js_script);
case 'excluded':
// surfer is not
$context['text'] .= Skin::build_block(i18n::s('You have not been enrolled into this interactive chat.'), 'caution');
break;
}
//
// trailer information
//
// add trailer information from the overlay, if any --opentok videos come from here
if (is_object($overlay)) {
$context['text'] .= $overlay->get_text('trailer', $item);
示例11: layout
//.........这里部分代码省略.........
$prefix .= STICKY_FLAG;
}
// signal articles to be published
if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > $context['now']) {
$prefix .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$suffix .= ' ' . LOCKED_FLAG;
}
// flag articles updated recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$suffix .= ' ' . EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$suffix .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= ' ' . UPDATED_FLAG;
}
// rating
if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
$suffix .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
}
// the full introductory text
if ($item['introduction']) {
$content .= Codes::beautify_introduction($item['introduction']);
} elseif (!is_object($overlay)) {
$article = new Article();
$article->load_by_content($item);
$content .= $article->get_teaser('teaser');
}
// insert overlay data, if any
if (is_object($overlay)) {
$content .= $overlay->get_text('list', $item);
}
// add details
$details = array();
// the author
if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
if ($item['edit_name'] == $item['create_name']) {
$details[] = sprintf(i18n::s('by %s'), ucfirst($item['create_name']));
} else {
$details[] = sprintf(i18n::s('by %s, %s'), ucfirst($item['create_name']), ucfirst($item['edit_name']));
}
}
// the modification date
if ($item['edit_date'] > NULL_DATE) {
$details[] = Skin::build_date($item['edit_date']);
}
// read the article
$details[] = Skin::build_link($url, i18n::s('More'), 'basic');
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic');
}
// info on related comments
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$link = Comments::get_url('article:' . $item['id'], 'list');
$details[] = Skin::build_link($link, sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'basic');
}
// discuss
if (Comments::allow_creation($item, $anchor)) {
$details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'basic');
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'basic');
}
// list categories by title, if any
if ($items =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
foreach ($items as $id => $attributes) {
// add background color to distinguish this category against others
if (isset($attributes['background_color']) && $attributes['background_color']) {
$attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>';
}
$details[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
}
}
// details
if (count($details)) {
$content .= '<div><span class="details">' . ucfirst(implode(' - ', $details)) . '</span></div>';
}
// insert a complete box
$text .= Skin::build_box(Skin::build_link($url, $prefix . $title . $suffix, 'basic', i18n::s('View the page')), $icon . $content, 'header1 ' . $class, 'article_' . $item['id']);
// stack boxes
if ($class == 'even') {
$class = 'odd';
} else {
$class = 'even';
}
}
// end of processing
SQL::free($result);
return $text;
}
示例12: layout
//.........这里部分代码省略.........
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
$text = ucfirst(trim($text));
// float the menu on the right
if (count($menu)) {
$text = '<div style="text-align: right">' . Skin::finalize_list($menu, 'menu') . '</div>' . $text;
}
// comment has been modified
if ($item['create_name'] && $item['edit_name'] != $item['create_name']) {
$text .= '<p class="details">' . ucfirst(sprintf(i18n::s('edited by %s %s'), $item['edit_name'], Skin::build_date($item['edit_date']))) . '</p>';
}
// potential replies to this comment
if ($item['type'] != 'notification') {
// look for replies
if ($replies = Comments::list_next($item['id'], 'replies')) {
if (is_array($replies)) {
$replies = Skin::build_list($replies, 'compact');
}
$text .= '<div>' . $replies . '</div>';
}
// allow to reply to this comment
if (Comments::allow_creation($anchor)) {
// the form to edit a comment
$text .= '<form method="post" action="' . $context['url_to_root'] . Comments::get_url($item['id'], 'reply') . '" onsubmit="return validateDocumentPost(this)" enctype="multipart/form-data"><div style="margin-top: 1em;">';
// reference the anchor page
$text .= '<input type="hidden" name="anchor" value="' . $item['anchor'] . '" />';
// remember the id of the replied comment
$text .= '<input type="hidden" name="previous_id" value="' . $item['id'] . '" />';
// notify watchers
$text .= '<input type="hidden" name="notify_watchers" value="Y" />';
// ensure id uniqueness
static $fuse_id;
if (!isset($fuse_id)) {
$fuse_id = 1;
} else {
$fuse_id++;
}
// a textarea that grow on focus
Page::insert_script('var reply' . $fuse_id . '=1;');
$text .= '<textarea name="description" id="reply' . $fuse_id . '"' . ' rows="1" cols="50"' . ' onfocus="if(reply' . $fuse_id . '){$(\'div#submit' . $fuse_id . '\').slideDown(600);reply' . $fuse_id . '=0;}">' . '</textarea>' . "\n";
// fix number of rows in firefox
Page::insert_script('$(function(){' . '$("textarea#reply' . $fuse_id . '")' . '.each(function(){' . 'var lineHeight = parseFloat($(this).css("line-height"));' . 'var lines = $(this).attr("rows")*1 || $(this).prop("rows")*1;' . '$(this).css("height", lines*lineHeight);' . '})' . '.autogrow();' . '});' . "\n");
// the submit button
$text .= '<div class="menu_bar" style="display: none;" id="submit' . $fuse_id . '">' . Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's') . '</div>';
// end of the form
$text .= '</div></form>';
}
}
// the main part of the comment, with an id
$text = '<td class="comment ' . $item['type'] . '" id="comment_' . $item['id'] . '">' . $text . '</td>';
// this is another row of the output
$rows[] = '<td class="author ' . $item['type'] . '">' . $author . '</td>' . $text;
}
// end of processing
SQL::free($result);
// sanity check
if (!count($rows)) {
return '';
}
// return a table
$output = Skin::table_prefix('yabb');
$count = 1;
foreach ($rows as $row) {
if ($count % 2) {
$output .= '<tr class="odd">' . $row . '</tr>';
} else {
$output .= '<tr class="even">' . $row . '</tr>';
}
$count++;
}
$output .= '</table>';
// process yacs codes
$output = Codes::beautify($output);
return $output;
}
示例13: strip_tags
$login_hook = 'anchor=' . $target_anchor;
}
// 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
示例14: die
Safe::header('Status: 401 Unauthorized', TRUE, 401);
die(i18n::s('You are not allowed to perform this operation.'));
// an anchor is mandatory
} elseif (!is_object($anchor)) {
Safe::header('Status: 404 Not Found', TRUE, 404);
die(i18n::s('No anchor has been found.'));
// the anchor has to be viewable by this surfer
} elseif (!$anchor->is_viewable()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
die(i18n::s('You are not allowed to perform this operation.'));
// robots cannot contribute
} elseif (isset($_REQUEST['message']) && Surfer::may_be_a_robot()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
die(i18n::s('You are not allowed to perform this operation.'));
// this anchor does not accept contributions
} elseif (isset($_REQUEST['message']) && is_object($anchor) && !Comments::allow_creation($anchor)) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
die(i18n::s('You are not allowed to perform this operation.'));
// a new contribution has been submitted
} elseif (isset($_REQUEST['message']) && trim($_REQUEST['message'])) {
// sanitize the message
$_REQUEST['message'] = str_replace(array("\r\n", "\r"), "\n", trim($_REQUEST['message']));
// protect from hackers
if (isset($_REQUEST['edit_name'])) {
$_REQUEST['edit_name'] = preg_replace(FORBIDDEN_IN_NAMES, '_', $_REQUEST['edit_name']);
}
if (isset($_REQUEST['edit_address'])) {
$_REQUEST['edit_address'] = encode_link($_REQUEST['edit_address']);
}
// append to previous comment during 10 minutes
$continuity_limit = gmstrftime('%Y-%m-%d %H:%M:%S', time() - 600);
示例15: layout
//.........这里部分代码省略.........
// use the title to label the link
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// signal restricted and private sections
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// this is another row of the output
$text .= '<tr class="' . $class_title . '"><th>' . $prefix . Skin::build_link($url, $title, 'basic', i18n::s('View the section')) . $suffix . '</th></tr>' . "\n";
// document most recent page here
$content = $prefix = $title = $suffix = $icon = '';
$menu = array();
// branches of this tree
$anchors = Sections::get_branch_at_anchor('section:' . $item['id']);
// get last post
$article =& Articles::get_newest_for_anchor($anchors, TRUE);
if ($article['id']) {
// permalink
$url = Articles::get_permalink($article);
// get the anchor
$anchor = Anchors::get($article['anchor']);
// get the related overlay, if any
$overlay = Overlay::load($item, 'section:' . $item['id']);
// use the title to label the link
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $article));
} else {
$title = Codes::beautify_title($article['title']);
}
// signal restricted and private articles
if ($article['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($article['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// the icon to put aside
if ($article['thumbnail_url']) {
$icon = $article['thumbnail_url'];
}
// the icon to put aside
if (!$icon && is_callable(array($anchor, 'get_bullet_url'))) {
$icon = $anchor->get_bullet_url();
}
if ($icon) {
$icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="" title="' . encode_field(i18n::s('View the page')) . '" /></a>';
}
// the introductory text
if ($article['introduction']) {
$content .= Codes::beautify_introduction($article['introduction']);
} elseif (!is_object($overlay)) {
$handle = new Article();
$handle->load_by_content($article);
$content .= $handle->get_teaser('teaser');
}
// insert overlay data, if any
if (is_object($overlay)) {
$content .= $overlay->get_text('list', $article);
}
// link to description, if any
if (trim($article['description'])) {
$menu[] = Skin::build_link($url, i18n::s('Read more') . MORE_IMG, 'span', i18n::s('View the page'));
}
// info on related files
if ($count = Files::count_for_anchor('article:' . $article['id'])) {
$menu[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related comments
if ($count = Comments::count_for_anchor('article:' . $article['id'])) {
$menu[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// discuss
if (Comments::allow_creation($article, $anchor)) {
$menu[] = Skin::build_link(Comments::get_url('article:' . $article['id'], 'comment'), i18n::s('Discuss'), 'span');
}
// the main anchor link
if (is_object($anchor) && (!isset($this->focus) || $article['anchor'] != $this->focus)) {
$menu[] = Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'span', i18n::s('View the section'));
}
// list up to three categories by title, if any
if ($items =& Members::list_categories_by_title_for_member('article:' . $article['id'], 0, 3, 'raw')) {
foreach ($items as $id => $attributes) {
$menu[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'span');
}
}
// append a menu
$content .= '<p>' . Skin::finalize_list($menu, 'menu') . '</p>';
// this is another row of the output
$text .= '<tr class="' . $class_detail . '"><td>' . '<h3 class="top"><span>' . Skin::build_link($url, $prefix . $title . $suffix, 'basic', i18n::s('View the page')) . '</span></h3>' . '<div class="content">' . $icon . $content . '</div>' . '</td></tr>' . "\n";
}
}
// end of processing
SQL::free($result);
$text .= Skin::table_suffix();
return $text;
}