本文整理汇总了PHP中Articles::is_owned方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::is_owned方法的具体用法?PHP Articles::is_owned怎么用?PHP Articles::is_owned使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Articles
的用法示例。
在下文中一共展示了Articles::is_owned方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: layout
/**
* list articles
*
* Accept following variants:
* - 'hits', compact plus the number of hits
* - 'no_author', for articles in the user page
* - 'category:xxx', if the list is displayed at categories/view.php
* - 'section:xxx', if the list is displayed at sections/view.php
*
* @param resource the SQL result
* @return array of resulting items, or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// sanity check
if (!isset($this->layout_variant)) {
$this->layout_variant = 'decorated';
}
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// 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']);
}
// initialize variables
$prefix = $suffix = $icon = '';
// flag sticky pages
if ($item['rank'] < 10000) {
$prefix .= STICKY_FLAG;
}
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$suffix .= ' ' . LOCKED_FLAG;
}
// flag articles that are dead, or created or updated very recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$prefix .= EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$suffix .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= ' ' . UPDATED_FLAG;
}
// signal articles to be published
if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
$prefix .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// the compact version
if ($this->layout_variant == 'compact') {
$items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL);
continue;
}
// with hits
if ($this->layout_variant == 'hits') {
if ($item['hits'] > 1) {
$suffix = ' <span class="details">- ' . Skin::build_number($item['hits'], i18n::s('hits')) . '</span>';
}
$items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL);
continue;
}
// introduction
$introduction = '';
if (is_object($overlay)) {
$introduction = $overlay->get_text('introduction', $item);
} else {
$introduction = $item['introduction'];
}
// the introductory text
if ($introduction) {
$suffix .= ' - ' . Codes::beautify_introduction($introduction);
// link to description, if any
if ($item['description']) {
$suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' ';
}
}
// insert overlay data, if any
//.........这里部分代码省略.........
示例2: allow_creation
/**
* check if new files can be added
*
* This function returns TRUE if files can be added to some place,
* and FALSE otherwise.
*
* @param array a set of item attributes, if any
* @param object an instance of the Anchor interface, if any
* @param string the type of item, e.g., 'article' or 'section'
* @return boolean TRUE or FALSE
*/
public static function allow_creation($item = NULL, $anchor = NULL, $variant = NULL)
{
global $context;
// guess the variant
if (!$variant) {
// most frequent case
if (isset($item['id'])) {
$variant = 'article';
} elseif (is_object($anchor)) {
$variant = $anchor->get_type();
} else {
return FALSE;
}
}
// attach a file to an article
if ($variant == 'article') {
// 'no initial upload' option
if (!isset($item['id']) && Articles::has_option('no_initial_upload', $anchor, $item)) {
return FALSE;
}
// 'no files' option
if (Articles::has_option('no_files', $anchor, $item)) {
return FALSE;
}
// attach a file to a user profile
} elseif ($variant == 'user') {
// associates can always proceed
if (Surfer::is_associate()) {
} elseif (!is_object($anchor) || !Surfer::get_id()) {
return FALSE;
} elseif ($anchor->get_reference() != 'user:' . Surfer::get_id()) {
return FALSE;
}
// other containers
} else {
// files have to be activated explicitly
if (isset($item['options']) && is_string($item['options']) && preg_match('/\\bwith_files\\b/i', $item['options'])) {
} elseif (!isset($item['id']) && is_object($anchor) && $anchor->has_option('with_files', FALSE)) {
} else {
return FALSE;
}
}
// surfer is not allowed to upload a file
if (!Surfer::may_upload()) {
return FALSE;
}
// surfer is an associate
if (Surfer::is_associate()) {
return TRUE;
}
// submissions have been disallowed
if (isset($context['users_without_submission']) && $context['users_without_submission'] == 'Y') {
return FALSE;
}
// only in articles
if ($variant == 'article') {
// surfer owns this item, or the anchor
if (Articles::is_owned($item, $anchor)) {
return TRUE;
}
// surfer is an editor, and the page is not private
if (isset($item['active']) && $item['active'] != 'N' && Articles::is_assigned($item['id'])) {
return TRUE;
}
// only in sections
} elseif ($variant == 'section') {
// surfer owns this item, or the anchor
if (Sections::is_owned($item, $anchor, TRUE)) {
return TRUE;
}
// surfer is an editor, and the section is not private
if (isset($item['active']) && $item['active'] != 'N' && Sections::is_assigned($item['id'])) {
return TRUE;
}
}
// surfer is an editor, and container is not private
if (isset($item['active']) && $item['active'] != 'N' && is_object($anchor) && $anchor->is_assigned()) {
return TRUE;
}
if (!isset($item['id']) && is_object($anchor) && !$anchor->is_hidden() && $anchor->is_assigned()) {
return TRUE;
}
// item has been locked
if (isset($item['locked']) && $item['locked'] == 'Y') {
return FALSE;
}
// anchor has been locked --only used when there is no item provided
if (!isset($item['id']) && is_object($anchor) && $anchor->has_option('locked')) {
return FALSE;
//.........这里部分代码省略.........
示例3: layout_newest
/**
* layout the newest articles
*
* caution: this function also updates page title directly, and this makes its call non-cacheable
*
* @param array the article
* @return string the rendered text
**/
function layout_newest($item)
{
global $context;
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// reset the rendering engine between items
Codes::initialize($url);
// build a title
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// title prefix & suffix
$text = $prefix = $suffix = '';
// flag articles updated recently
if ($context['site_revisit_after'] < 1) {
$context['site_revisit_after'] = 2;
}
$context['fresh'] = gmstrftime('%Y-%m-%d %H:%M:%S', mktime(0, 0, 0, date("m"), date("d") - $context['site_revisit_after'], date("Y")));
// link to permalink
if (Surfer::is_empowered()) {
$title = Skin::build_box_title($title, $url, i18n::s('Permalink'));
}
// signal articles to be published
if ($item['publish_date'] <= NULL_DATE) {
$prefix .= DRAFT_FLAG;
} else {
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 expired article
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$suffix .= EXPIRED_FLAG;
}
// update page title directly
$text .= Skin::build_block($prefix . $title . $suffix, 'title');
// if this article has a specific icon, use it
if ($item['icon_url']) {
$icon = $item['icon_url'];
} elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
$icon = $anchor->get_icon_url();
}
// if we have a valid image
if (preg_match('/(.gif|.jpg|.jpeg|.png)$/i', $icon)) {
// fix relative path
if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) {
$icon = $context['url_to_root'] . $icon;
}
// flush the image on the right
$text .= '<img src="' . $icon . '" class="right_image" alt="" />';
}
// article rating, if the anchor allows for it
if (!is_object($anchor) || !$anchor->has_option('without_rating')) {
// report on current rating
$label = '';
if ($item['rating_count']) {
$label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ';
}
$label .= i18n::s('Rate this page');
// allow for rating
$text .= Skin::build_link(Articles::get_url($item['id'], 'like'), $label, 'basic');
}
// the introduction text, if any
if (is_object($overlay)) {
$text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
} else {
$text .= Skin::build_block($item['introduction'], 'introduction');
}
// insert overlay data, if any
if (is_object($overlay)) {
$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'))) {
//.........这里部分代码省略.........
示例4: layout
/**
* list articles for search requests
*
* @param resource the SQL result
* @return array of resulting items ($score, $summary), or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of array($score, $summary)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// one box at a time
$box = '';
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// 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']);
}
// initialize variables
$prefix = $suffix = $icon = '';
// flag sticky pages
if ($item['rank'] < 10000) {
$prefix .= STICKY_FLAG;
}
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$suffix .= ' ' . LOCKED_FLAG;
}
// flag articles that are dead, or created or updated very recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$prefix .= EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$suffix .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= ' ' . UPDATED_FLAG;
}
// signal articles to be published
if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
$prefix .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// introduction
$introduction = '';
if (is_object($overlay)) {
$introduction = $overlay->get_text('introduction', $item);
} else {
$introduction = $item['introduction'];
}
// the introductory text
if ($introduction) {
$suffix .= ' - ' . Codes::beautify_introduction($introduction);
// link to description, if any
if ($item['description']) {
$suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' ';
}
}
// insert overlay data, if any
if (is_object($overlay)) {
$suffix .= $overlay->get_text('list', $item);
}
// details
$details = array();
// the author
if ($item['create_name'] != $item['edit_name']) {
$details[] = sprintf(i18n::s('by %s, %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']));
} else {
$details[] = sprintf(i18n::s('by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']));
}
// the last action
$details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
// the number of hits
if (Surfer::is_logged() && $item['hits'] > 1) {
$details[] = Skin::build_number($item['hits'], i18n::s('hits'));
}
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
//.........这里部分代码省略.........
示例5:
// review command provided to container owners
if (is_object($anchor) && $anchor->is_owned()) {
Skin::define_img('ARTICLES_STAMP_IMG', 'articles/stamp.gif');
$context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'stamp'), ARTICLES_STAMP_IMG . i18n::s('Stamp'));
}
// lock command provided to associates and authenticated editors
if (Articles::is_owned($item, $anchor)) {
if (!isset($item['locked']) || $item['locked'] == 'N') {
Skin::define_img('ARTICLES_LOCK_IMG', 'articles/lock.gif');
$context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'lock'), ARTICLES_LOCK_IMG . i18n::s('Lock'));
} else {
Skin::define_img('ARTICLES_UNLOCK_IMG', 'articles/unlock.gif');
$context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'lock'), ARTICLES_UNLOCK_IMG . i18n::s('Unlock'));
}
}
// delete command
if (Articles::allow_deletion($item, $anchor)) {
Skin::define_img('ARTICLES_DELETE_IMG', 'articles/delete.gif');
$context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'delete'), ARTICLES_DELETE_IMG . i18n::s('Delete this page'));
}
// duplicate command provided to container owners
if (Articles::is_owned(NULL, $anchor)) {
Skin::define_img('ARTICLES_DUPLICATE_IMG', 'articles/duplicate.gif');
$context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'duplicate'), ARTICLES_DUPLICATE_IMG . i18n::s('Duplicate this page'));
}
// use date of last modification into etag computation
if (isset($item['edit_date'])) {
$context['page_date'] = $item['edit_date'];
}
// render the skin
render_skin();
示例6: elseif
}
// page title
if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > $context['now']) {
$context['page_title'] .= DRAFT_FLAG;
}
if (isset($item['active']) && $item['active'] == 'R') {
$context['page_title'] .= RESTRICTED_FLAG;
} elseif (isset($item['active']) && $item['active'] == 'N') {
$context['page_title'] .= PRIVATE_FLAG;
}
if (is_object($overlay)) {
$context['page_title'] .= $overlay->get_text('title', $item);
} elseif (isset($item['title'])) {
$context['page_title'] .= $item['title'];
}
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$context['page_title'] .= ' ' . LOCKED_FLAG;
}
// page language, if any
if (isset($item['language']) && $item['language'] && $item['language'] != 'none') {
$context['page_language'] = $item['language'];
}
// page canonical link
$context['page_link'] = Articles::get_permalink($item);
// not found -- help web crawlers
if (!isset($item['id'])) {
include '../error.php';
// permission denied
} elseif (!$permitted) {
// make it clear to crawlers
if (Surfer::is_crawler()) {
示例7: layout
/**
* list articles as topics in a forum
*
* @param resource the SQL result
* @return string the rendered text
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// start a table
$text .= Skin::table_prefix('jive');
// headers
$text .= Skin::table_row(array(i18n::s('Topic'), i18n::s('Content')), 'header');
// build a list of articles
$odd = FALSE;
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// 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']);
}
// 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
//.........这里部分代码省略.........
示例8: layout
/**
* list articles as rows in a table
*
* @param resource the SQL result
* @return string the rendered text
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// build a list of articles
$rows = array();
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// get the related overlay
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// reset everything
$id = $summary = $owner = $type = $status = $update = $progress = '';
// link to the page
$id = Skin::build_link($url, $item['id'], 'basic');
// 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')) {
$summary .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$summary .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$summary .= RESTRICTED_FLAG;
}
// indicate the id in the hovering popup
$hover = i18n::s('View the page');
if (Surfer::is_member()) {
$hover .= ' [article=' . $item['id'] . ']';
}
// use the title to label the link
if (is_object($overlay)) {
$label = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$label = Codes::beautify_title($item['title']);
}
// use the title as a link to the page
$summary .= Skin::build_link($url, $label, 'basic', $hover);
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$summary .= ' ' . LOCKED_FLAG;
}
// flag articles updated recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$summary .= ' ' . EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$summary .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$summary .= ' ' . UPDATED_FLAG;
}
// 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[] = FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// 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);
}
// comments
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
Skin::define_img('COMMENTS_LIST_IMG', 'comments/list.gif');
$details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), COMMENTS_LIST_IMG . sprintf(i18n::ns('%d comment', '%d comments', $count), $count));
}
// combine in-line details
if (count($details)) {
$summary .= ' <span class="details">' . trim(implode(' ', $details)) . '</span>';
}
// dates
$summary .= BR . '<span class="details">' . join(BR, Articles::build_dates($anchor, $item)) . '</span>';
// display all tags
if ($item['tags']) {
$summary .= BR . '<span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
}
// page owner
if (isset($item['owner_id']) && ($owner = Users::get($item['owner_id']))) {
$owner = Users::get_link($owner['full_name'], $owner['email'], $owner['id']);
}
// type is provided by the overlay
if (is_object($overlay)) {
$type = $overlay->get_value('type', '');
}
//.........这里部分代码省略.........
示例9: elseif
if ($id) {
$anchor = Anchors::get($id);
}
// which page should be displayed
if (isset($_REQUEST['page'])) {
$page = $_REQUEST['page'];
} elseif (isset($context['arguments'][2])) {
$page = $context['arguments'][2];
} else {
$page = 1;
}
$page = max(1, intval($page));
// only anchor owners can proceed
if (is_object($anchor) && $anchor->is_owned()) {
$permitted = TRUE;
} elseif (is_object($anchor) && $anchor->get_type() == 'article' && Articles::is_owned(NULL, $anchor)) {
$permitted = TRUE;
} elseif (is_object($anchor) && $anchor->get_type() == 'section' && Sections::is_owned(NULL, $anchor)) {
$permitted = TRUE;
} else {
$permitted = FALSE;
}
// load the skin, maybe with a variant
load_skin('versions', $anchor);
if (!defined('VERSIONS_PER_PAGE')) {
define('VERSIONS_PER_PAGE', 25);
}
// clear the tab we are in, if any
if (is_object($anchor)) {
$context['current_focus'] = $anchor->get_focus();
}
示例10: layout
/**
* list articles for manual review
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// 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']);
}
// initialize variables
$prefix = $suffix = '';
// flag sticky pages
if ($item['rank'] < 10000) {
$prefix .= STICKY_FLAG;
}
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$suffix .= ' ' . LOCKED_FLAG;
}
// flag articles that are dead, or created or updated very recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$prefix .= EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$suffix .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= ' ' . UPDATED_FLAG;
}
// signal articles to be published
if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
$prefix .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// details
$details = array();
// the author(s)
if ($item['create_name'] != $item['edit_name']) {
$details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']);
} else {
$details[] = sprintf(i18n::s('by %s'), $item['create_name']);
}
// the last action
$details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
// the number of hits
if (Surfer::is_logged() && $item['hits'] > 1) {
$details[] = Skin::build_number($item['hits'], i18n::s('hits'));
}
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// info on related comments
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// append details to the suffix
$suffix .= ' - <span class="details">' . ucfirst(trim(implode(', ', $details))) . '</span>';
// commands to review the article
$menu = array();
// read the page
$menu = array_merge($menu, array($url => i18n::s('Read')));
// validate the page
$menu = array_merge($menu, array('articles/stamp.php?id=' . $item['id'] . '&confirm=review' => i18n::s('Validate')));
// add a menu
$suffix .= ' ' . Skin::build_list($menu, 'menu');
// list all components for this item
$items[$url] = array($prefix, $title, $suffix, 'basic', NULL);
}
//.........这里部分代码省略.........
示例11: array
//
$text = '';
// provide information to section owner
if (isset($item['id'])) {
// owner
$label = i18n::s('Owner');
$input = '';
if (isset($item['owner_id'])) {
if ($owner = Users::get($item['owner_id'])) {
$input = Users::get_link($owner['full_name'], $owner['email'], $owner['id']);
} else {
$input = i18n::s('No owner has been found.');
}
}
// change the owner
if (Articles::is_owned($item, $anchor) || Surfer::is_associate()) {
$input .= ' <span class="details">' . Skin::build_link(Articles::get_url($item['id'], 'own'), i18n::s('Change'), 'button') . '</span>';
}
$fields[] = array($label, $input);
}
// the active flag: Yes/public, Restricted/logged, No/associates --we don't care about inheritance, to enable security changes afterwards
if (!isset($item['id']) || $cur_article->is_owned() || Surfer::is_associate()) {
$label = i18n::s('Access');
$input = Skin::build_active_set_input($item);
$hint = Skin::build_active_set_hint($anchor);
$fields[] = array($label, $input, $hint);
}
// locked: Yes / No
$label = i18n::s('Locker');
$input = '<input type="radio" name="locked" value="N"';
if (!isset($item['locked']) || $item['locked'] != 'Y') {
示例12: layout
/**
* list articles
*
* @param resource the SQL result
* @return array of resulting items, or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// 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']);
}
// initialize variables
$prefix = $suffix = $icon = '';
// flag sticky pages
if ($item['rank'] < 10000) {
$prefix .= STICKY_FLAG;
}
// signal articles to be published
if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
$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 that are dead, or created or updated very recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$prefix .= 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_rating_img((int) round($item['rating_sum'] / $item['rating_count']));
}
// info on related comments
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$suffix .= ' (' . $count . ')';
}
// details
$details = array();
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// flag popular pages
if ($item['hits'] > 300) {
$details[] = POPULAR_FLAG;
}
// the main anchor link
if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) {
$details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section'));
}
// combine in-line details
if (count($details)) {
$suffix .= ' - <span class="details">' . trim(implode(', ', $details)) . '</span>';
}
// list all components for this item
$items[$url] = array($prefix, $title, $suffix, 'article', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例13: layout
/**
* list articles as rows in a table
*
* @param resource the SQL result
* @return string the rendered text
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// we list pages for one surfer
// sanity check
if (!isset($this->focus)) {
$this->focus = Surfer::get_id();
}
// build a list of articles
Skin::define_img('CHECKED_IMG', 'ajax/accept.png', '*');
$rows = array();
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// get the related overlay
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// reset everything
$summary = $update = $owner = $editor = $watcher = '';
// 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')) {
$summary .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$summary .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$summary .= RESTRICTED_FLAG;
}
// indicate the id in the hovering popup
$hover = i18n::s('View the page');
if (Surfer::is_member()) {
$hover .= ' [article=' . $item['id'] . ']';
}
// use the title to label the link
if (is_object($overlay)) {
$label = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$label = Codes::beautify_title($item['title']);
}
// use the title as a link to the page
$summary .= Skin::build_link($url, $label, 'basic', $hover);
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$summary .= ' ' . LOCKED_FLAG;
}
// flag articles updated recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$summary .= ' ' . EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$summary .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$summary .= ' ' . UPDATED_FLAG;
}
// insert overlay data, if any
if (is_object($overlay)) {
$summary .= $overlay->get_text('list', $item);
}
// attachment details
$details = array();
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// comments
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// the main anchor link
if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) {
$details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'basic'));
}
// combine in-line details
if (count($details)) {
$summary .= BR . '<span class="details">' . trim(implode(' · ', $details)) . '</span>';
}
// display all tags
if ($item['tags']) {
$summary .= BR . '<span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
}
// dates
//.........这里部分代码省略.........
示例14: layout
/**
* list articles
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// build a list of articles
$item_count = 0;
$items = array();
include_once $context['path_to_root'] . 'articles/article.php';
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// next item
$item_count += 1;
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// one box per article
$prefix = $suffix = $icon = '';
// build a box around two first articles
if ($item_count == 1) {
$text .= '<div class="recent">' . "\n";
} elseif ($item_count == 3) {
$text .= '</div><br style="clear: left;" />' . "\n";
}
// layout newest articles
if ($item_count < 3) {
// style to apply
switch ($item_count) {
case 1:
$text .= '<div class="left">';
break;
case 2:
$text .= '<div class="right">';
break;
}
// the icon to put aside
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
} elseif (is_object($anchor)) {
$icon = $anchor->get_thumbnail_url();
}
if ($icon) {
$text .= '<a href="' . $context['url_to_root'] . $url . '" title="' . i18n::s('View the page') . '"><img src="' . $icon . '" class="left_image" alt="" /></a>';
}
$text .= $this->layout_newest($item, $anchor) . '</div>' . "\n";
// layout recent articles
} else {
// 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']);
}
// flag sticky pages
if ($item['rank'] < 10000) {
$prefix .= STICKY_FLAG;
}
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$suffix .= ' ' . LOCKED_FLAG;
}
// flag articles that are dead, or created or updated very recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$prefix .= EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$suffix .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= ' ' . UPDATED_FLAG;
}
// signal articles to be published
if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
$prefix .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// the introductory text
$introduction = '';
if (is_object($overlay)) {
$introduction .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
} elseif ($item['introduction']) {
//.........这里部分代码省略.........
示例15: layout
/**
* list articles as topics in a forum
*
* @param resource the SQL result
* @return string the rendered text
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// allow for complete styling
$text = '<div class="last_articles">';
// build a list of articles
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// get the related overlay
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// build a title
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// reset everything
$prefix = $label = $suffix = $icon = '';
// 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')) {
$prefix .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// flag expired articles
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$prefix .= EXPIRED_FLAG . ' ';
} elseif ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$suffix .= ' ' . LOCKED_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');
}
// indicate the id in the hovering popup
$hover = i18n::s('View the page');
if (Surfer::is_member()) {
$hover .= ' [article=' . $item['id'] . ']';
}
// one box per update
$text .= '<div class="last_article" >';
// use the title as a link to the page
$text .= Skin::build_block($prefix . ucfirst($title) . $suffix, 'header1');
// some details about this page
$details = array();
// page starter and date
if ($item['create_name']) {
$details[] = sprintf(i18n::s('Started by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id'])) . ' ' . Skin::build_date($item['create_date']);
}
// page last modification
if ($item['edit_date'] && $item['edit_action'] == 'article:update' && $item['edit_name']) {
$details[] = Anchors::get_action_label($item['edit_action']) . ' ' . sprintf(i18n::s('by %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'])) . ' ' . Skin::build_date($item['edit_date']);
}
// friends
if ($friends =& Members::list_users_by_posts_for_anchor('article:' . $item['id'], 0, USERS_LIST_SIZE, 'comma5', $item['create_id'])) {
$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)) {
//.........这里部分代码省略.........