本文整理汇总了PHP中Files::list_by_date_for_anchor方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::list_by_date_for_anchor方法的具体用法?PHP Files::list_by_date_for_anchor怎么用?PHP Files::list_by_date_for_anchor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Files
的用法示例。
在下文中一共展示了Files::list_by_date_for_anchor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cascade
/**
* cascade to children
*
* @param string referencing of the changed anchor
* @param string rights to be cascaded (e.g., 'Y', 'R' or 'N')
*/
public static function cascade($reference, $active)
{
global $context;
// only sections may have sub-sections
if (strpos($reference, 'section:') === 0) {
// cascade to sub-sections
if ($items = Sections::list_for_anchor($reference, 'raw')) {
// cascade to each section individually
foreach ($items as $id => $item) {
// limit actual rights
$item['active'] = Anchors::ceil_rights($active, $item['active_set']);
$query = "UPDATE " . SQL::table_name('sections') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
SQL::query($query);
// cascade to children
Anchors::cascade('section:' . $item['id'], $item['active']);
}
}
}
// only categories may have sub-categories
if (strpos($reference, 'category:') === 0) {
// cascade to sub-categories
if ($items = Categories::list_for_anchor($reference, 'raw')) {
// cascade to each section individually
foreach ($items as $id => $item) {
// limit actual rights
$item['active'] = Anchors::ceil_rights($active, $item['active_set']);
$query = "UPDATE " . SQL::table_name('categories') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
SQL::query($query);
// cascade to children
Anchors::cascade('category:' . $item['id'], $item['active']);
}
}
}
// only sections may have articles
if (strpos($reference, 'section:') === 0) {
// cascade to articles --up to 3000
if ($items =& Articles::list_for_anchor_by('edition', $reference, 0, 3000, 'raw')) {
// cascade to each section individually
foreach ($items as $id => $item) {
// limit actual rights
$item['active'] = Anchors::ceil_rights($active, $item['active_set']);
$query = "UPDATE " . SQL::table_name('articles') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
SQL::query($query);
// cascade to children
Anchors::cascade('article:' . $item['id'], $item['active']);
}
}
}
// cascade to files --up to 3000
if ($items = Files::list_by_date_for_anchor($reference, 0, 3000, 'raw')) {
// cascade to each section individually
foreach ($items as $id => $item) {
// limit actual rights
$item['active'] = Anchors::ceil_rights($active, $item['active_set']);
$query = "UPDATE " . SQL::table_name('files') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
SQL::query($query);
}
}
}
示例2: 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);
//.........这里部分代码省略.........
示例3: array
//
// the list of related files if not at another follow-up page
if (!$zoom_type || $zoom_type == 'files') {
// build a complete box
$box = array('bar' => array(), 'text' => '');
// count the number of files in this category
if ($count = Files::count_for_anchor('category:' . $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')
$offset = ($zoom_index - 1) * FILES_PER_PAGE;
if (isset($item['options']) && preg_match('/\\bfiles_by_title\\b/i', $item['options'])) {
$items = Files::list_by_title_for_anchor('category:' . $item['id'], $offset, FILES_PER_PAGE, 'category:' . $item['id']);
} else {
$items = Files::list_by_date_for_anchor('category:' . $item['id'], $offset, FILES_PER_PAGE, 'category:' . $item['id']);
}
if (is_array($items)) {
$box['text'] .= Skin::build_list($items, 'decorated');
} else {
$box['text'] .= $items;
}
// navigation commands for files
$home = Categories::get_permalink($item);
$prefix = Categories::get_url($item['id'], 'navigate', 'files');
$box['bar'] = array_merge($box['bar'], Skin::navigate($home, $prefix, $count, FILES_PER_PAGE, $zoom_index));
}
// the command to post a new file
$url = 'files/edit.php?anchor=' . urlencode('category:' . $item['id']);
if (Files::allow_creation($item, $anchor, 'category')) {
Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif');
示例4:
$items =& Members::list_articles_by_date_for_anchor('category:' . $item['id'], 0, 50);
}
// actually render the html for the section
if ($items) {
$context['text'] .= $section . Skin::build_list($items, 'decorated');
}
//
// the files section
//
// title
$section = Skin::build_block(i18n::s('Files'), 'title');
// list files by date (default) or by title (option :files_by_title:)
if (preg_match('/\\bfiles_by_title\\b/i', $item['options'])) {
$items = Files::list_by_title_for_anchor('category:' . $item['id'], 0, 300, 'category:' . $item['id']);
} else {
$items = Files::list_by_date_for_anchor('category:' . $item['id'], 0, 300, 'category:' . $item['id']);
}
// actually render the html for the section
if ($items) {
$context['text'] .= $section . Skin::build_list($items, 'decorated');
}
//
// the links section
//
// title
$section = Skin::build_block(i18n::s('See also'), 'title');
// list links by date (default) or by title (option :links_by_title:)
if (preg_match('/\\blinks_by_title\\b/i', $item['options'])) {
$items = Links::list_by_title_for_anchor('category:' . $item['id'], 0, 50);
} else {
$items = Links::list_by_date_for_anchor('category:' . $item['id'], 0, 50);
示例5: array
$embedded = Codes::list_embedded($item['description']);
}
// build a complete box
$box = array('bar' => array(), 'text' => '');
// count the number of files in this section
if ($count = Files::count_for_anchor('section:' . $item['id'], FALSE, $embedded)) {
$attachments_count += $count;
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 (preg_match('/\\bfiles_by_title\\b/i', $item['options'])) {
$items = Files::list_by_title_for_anchor('section:' . $item['id'], $offset, FILES_PER_PAGE, 'section:' . $item['id'], $embedded);
} else {
$items = Files::list_by_date_for_anchor('section:' . $item['id'], $offset, FILES_PER_PAGE, 'section:' . $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;
}
// navigation commands for files
$home = Sections::get_permalink($item);
$prefix = Sections::get_url($item['id'], 'navigate', 'files');
$box['bar'] = array_merge($box['bar'], Skin::navigate($home, $prefix, $count, FILES_PER_PAGE, $zoom_index));
}
// the command to post a new file -- check 'with_files' option
if (Files::allow_creation($item, $anchor, 'section')) {
Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif');
示例6: layout
/**
* list categories
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return plain text
$text = '';
// process all items in the list
while ($item = SQL::fetch($result)) {
// one box per category
$box['title'] = '';
$box['text'] = '';
// use the title to label the link
$box['title'] = Skin::strip($item['title'], 50);
// list related categories, if any
if ($items = Categories::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'compact')) {
foreach ($items as $url => $label) {
if (is_array($label)) {
$label = $label[1];
}
$box['text'] .= '<li>' . Skin::build_link($url, $label, 'category') . '</li>' . "\n";
}
}
// info on related sections
$items =& Members::list_sections_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
if ($items) {
foreach ($items as $url => $label) {
if (is_array($label)) {
$label = $label[1];
}
$box['text'] .= '<li>' . Skin::build_link($url, $label, 'section') . '</li>' . "\n";
}
}
// info on related articles
if (isset($item['options']) && preg_match('/\\barticles_by_title\\b/i', $item['options'])) {
$items =& Members::list_articles_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
} else {
$items =& Members::list_articles_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
}
if ($items) {
foreach ($items as $url => $label) {
if (is_array($label)) {
$label = $label[1];
}
$box['text'] .= '<li>' . Skin::build_link($url, $label, 'article') . '</li>' . "\n";
}
}
// info on related files
if (isset($item['options']) && preg_match('/\\bfiles_by_title\\b/i', $item['options'])) {
$items = Files::list_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'category:' . $item['id']);
} else {
$items = Files::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'category:' . $item['id']);
}
if ($items) {
foreach ($items as $url => $label) {
if (is_array($label)) {
$label = $label[1];
}
$box['text'] .= '<li>' . Skin::build_link($url, $label, 'file') . '</li>' . "\n";
}
}
// info on related comments
include_once $context['path_to_root'] . 'comments/comments.php';
if ($items = Comments::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'compact')) {
foreach ($items as $url => $label) {
if (is_array($label)) {
$label = $label[1];
}
$box['text'] .= '<li>' . Skin::build_link($url, $label, 'comment') . '</li>' . "\n";
}
}
// info on related links
include_once $context['path_to_root'] . 'links/links.php';
if (isset($item['options']) && preg_match('/\\blinks_by_title\\b/i', $item['options'])) {
$items = Links::list_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
} else {
$items = Links::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
}
if ($items) {
foreach ($items as $url => $label) {
if (is_array($label)) {
$label = $label[1];
}
$box['text'] .= '<li>' . Skin::build_link($url, $label) . '</li>' . "\n";
}
}
// add a direct link to the category
if (Surfer::is_associate()) {
$box['title'] .= ' ' . Skin::build_link(Categories::get_permalink($item), MORE_IMG, 'basic');
//.........这里部分代码省略.........
示例7: array
// use adequate label
if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
$context['text'] .= Skin::build_block($label, 'title') . '<div>' . $description . "</div>\n";
} else {
$context['text'] .= $description . "\n";
}
}
//
// attached files
//
// list files by date (default) or by title (option :files_by_title:)
$items = array();
if (Articles::has_option('files_by', $anchor, $item) == 'title') {
$items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, 300, 'compact');
} else {
$items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, 300, 'compact');
}
// actually list items
if (count($items)) {
$context['text'] .= Skin::build_box(i18n::s('Files'), utf8::to_unicode(Skin::build_list($items, 'compact')));
}
//
// attached comments
//
// list immutable comments by date
$items = Comments::list_by_date_for_anchor('article:' . $item['id'], 0, 500, 'excerpt');
// actually list items
if ($items) {
$context['text'] .= Skin::build_box(i18n::s('Comments'), utf8::to_unicode($items));
}
//
示例8: layout
/**
* list sections
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// the maximum number of items per section
if (!defined('MAXIMUM_ITEMS_PER_SECTION')) {
define('MAXIMUM_ITEMS_PER_SECTION', 100);
}
// we return plain text
$text = '';
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
$family = '';
while ($item = SQL::fetch($result)) {
// change the family
if ($item['family'] != $family) {
$family = $item['family'];
// show the family
$text .= '<h2><span>' . $family . ' </span></h2>' . "\n";
}
// get the related overlay, if any
$overlay = Overlay::load($item, 'section:' . $item['id']);
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// one box per section
$box = array('title' => '', 'text' => '');
// box content
$elements = array();
// use the title to label the link
if (is_object($overlay)) {
$box['title'] .= Codes::beautify_title($overlay->get_text('title', $item));
} else {
$box['title'] .= Codes::beautify_title($item['title']);
}
$details = array();
// info on related articles
if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
$order = $matches[1];
} else {
$order = 'edition';
}
$items =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact');
if (@count($items)) {
// mention the number of items in folded title
$details[] = sprintf(i18n::ns('%d page', '%d pages', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
$prefix = $suffix = '';
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
$elements[] = $prefix . Skin::build_link($url, $label, 'article') . $suffix;
}
}
// info on related files
if (Sections::has_option('files_by', $anchor, $item) == 'title') {
$items = Files::list_by_title_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact');
} else {
$items = Files::list_by_date_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact');
}
if ($items) {
// mention the number of sections in folded title
$details[] = sprintf(i18n::ns('%d file', '%d files', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
$elements[] = $prefix . Skin::build_link($url, $label, 'file') . $suffix;
}
}
// info on related comments
if ($items = Comments::list_by_date_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact', TRUE)) {
// mention the number of sections in folded title
$details[] = sprintf(i18n::ns('%d comment', '%d comments', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
$prefix = $suffix = '';
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
//.........这里部分代码省略.........
示例9: layout
/**
* list pages
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// allow for multiple calls
static $accordion_id;
if (!isset($accordion_id)) {
$accordion_id = 1;
} else {
$accordion_id++;
}
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// the maximum number of items per article
if (!defined('MAXIMUM_ITEMS_PER_ACCORDION')) {
define('MAXIMUM_ITEMS_PER_ACCORDION', 100);
}
// we return plain text
$text = '';
// type of listed object
$items_type = $this->listed_type;
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
$family = '';
while ($item = SQL::fetch($result)) {
// get the object interface, this may load parent and overlay
$entity = new $items_type($item);
// change the family (layout of sections)
if (isset($item['family']) && $item['family'] != $family) {
$family = $item['family'];
// show the family
$text .= '<h2><span>' . $family . ' </span></h2>' . "\n";
}
// one box per page
$box = array('title' => '', 'text' => '');
// signal entity to be published
if (isset($item['publish_date']) && ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S'))) {
$box['title'] .= DRAFT_FLAG;
}
// signal entity to be activated
if (isset($item['activation_date']) && $item['activation_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
$box['title'] .= DRAFT_FLAG;
}
// signal restricted and private entity
if ($item['active'] == 'N') {
$box['title'] .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$box['title'] .= RESTRICTED_FLAG;
}
// use the title to label the link
if (is_object($entity->overlay)) {
$box['title'] .= Codes::beautify_title($entity->overlay->get_text('title', $item));
} else {
$box['title'] .= Codes::beautify_title($item['title']);
}
// box content
$elements = array();
// complement the title with interesting details
$details = array();
// info on related article, only for sections
if ($items_type == 'section') {
if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
$order = $matches[1];
} else {
$order = 'edition';
}
$items =& Articles::list_for_anchor_by($order, $entity->get_reference(), 0, MAXIMUM_ITEMS_PER_ACCORDION + 1, 'compact');
if (@count($items)) {
// mention the number of items in folded title
$details[] = sprintf(i18n::ns('%d page', '%d pages', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
$prefix = $suffix = '';
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
$elements[] = $prefix . Skin::build_link($url, $label, 'article') . $suffix;
}
}
}
// info on related files
if ($entity->has_option('files_by') == 'title') {
$items = Files::list_by_title_for_anchor($entity->get_reference(), 0, MAXIMUM_ITEMS_PER_ACCORDION + 1, 'compact');
} else {
$items = Files::list_by_date_for_anchor($entity->get_reference(), 0, MAXIMUM_ITEMS_PER_ACCORDION + 1, 'compact');
}
if ($items) {
//.........这里部分代码省略.........
示例10: layout
/**
* list sections
*
* Accept following variants:
* - 'full' - include anchor information -- also the default value
*
* @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, 'section:' . $item['id']);
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Sections::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 sections that are draft, dead, or created or updated very recently
if ($item['activation_date'] >= $context['now']) {
$prefix .= DRAFT_FLAG;
} elseif ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$prefix .= EXPIRED_FLAG;
}
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
// signal restricted and private sections
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// the introductory text
if ($item['introduction']) {
$suffix .= ' - ' . Codes::beautify_introduction($item['introduction']);
}
// details and content
$details = array();
$content = array();
// count related sub-elements
$related_count = 0;
// info on related articles
if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
$related_count += $count;
// add related articles if necessary
if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
$order = $matches[1];
} else {
$order = 'edition';
}
if (count($details) < YAHOO_LIST_SIZE && ($related =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) {
foreach ($related as $link => $label) {
$sub_prefix = $sub_suffix = $sub_hover = '';
if (is_array($label)) {
$sub_prefix = $label[0];
$sub_suffix = $label[2];
if (@$label[5]) {
$sub_hover = $label[5];
}
$label = $label[1];
}
$content[$link] = array($sub_prefix, $label, $sub_suffix, 'basic', '', $sub_hover);
}
}
}
// info on related files
if ($count = Files::count_for_anchor('section:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
$related_count += $count;
// add related files if necessary
if (count($details) < YAHOO_LIST_SIZE && ($related = Files::list_by_date_for_anchor('section:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) {
foreach ($related as $link => $label) {
//.........这里部分代码省略.........
示例11: substr
$information .= $overlay->get_text('view', $item);
}
// the full text
if (is_object($overlay)) {
$description = $overlay->get_text('description', $item);
} else {
$description = $item['description'];
}
$information .= Skin::build_block($description, 'description');
// birth date, if any, and only for authenticated surfers
if (isset($item['birth_date']) && $item['birth_date'] > NULL_DATE && Surfer::is_logged()) {
$information .= '<p>' . i18n::s('Birth date') . ' ' . substr($item['birth_date'], 0, 10) . '</p>';
}
// list files
//
$items = Files::list_by_date_for_anchor('user:' . $item['id'], 0, FILES_PER_PAGE, 'no_author');
if (is_array($items)) {
$items = Skin::build_list($items, 'decorated');
}
// local menu
$menu = array();
// the command to post a new file
if ((Surfer::is($item['id']) || Surfer::is_associate()) && Surfer::may_upload()) {
Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif');
$menu[] = Skin::build_link('files/edit.php?anchor=user:' . $item['id'], FILES_UPLOAD_IMG . i18n::s('Add a file'), 'span');
}
if (count($menu)) {
$items = Skin::finalize_list($menu, 'menu_bar') . $items;
}
if ($items) {
$information .= Skin::build_box(i18n::s('Files'), $items);
示例12: elseif
$box['text'] .= Skin::build_list($items, 'decorated');
} elseif (is_string($items)) {
$box['text'] .= $items;
}
if ($box['text']) {
$context['text'] .= Skin::build_box(i18n::s('What is new?'), $box['text']);
}
}
//
// attached files
//
// list files by date (default) or by title (option :files_by_title:)
if (preg_match('/\\bfiles_by_title\\b/i', $item['options'])) {
$items = Files::list_by_title_for_anchor('section:' . $item['id'], 0, 300, 'section:' . $item['id']);
} else {
$items = Files::list_by_date_for_anchor('section:' . $item['id'], 0, 300, 'section:' . $item['id']);
}
// actually render the html for the section
if ($items) {
$context['text'] .= Skin::build_box(i18n::s('Files'), Skin::build_list($items, 'decorated'));
}
//
// the comments section
//
// layout for printed comments
$layout = 'no_anchor';
// the maximum number of comments per page
if (is_object($layout)) {
$items_per_page = $layout->items_per_page();
} else {
$items_per_page = COMMENTS_PER_PAGE;
示例13: elseif
$context['page_title'] = i18n::s('Files');
// stop crawlers
if (Surfer::is_crawler()) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// an anchor is mandatory
} elseif (!is_object($anchor)) {
Safe::header('Status: 404 Not Found', TRUE, 404);
Logger::error(i18n::s('No anchor has been found.'));
// provide updated information for this anchor
} else {
// list files by date (default) or by title (option files_by_title)
if ($anchor->has_option('files_by') == 'title') {
$output = Files::list_by_title_for_anchor($anchor->get_reference(), 0, 20, 'compact');
} else {
$output = Files::list_by_date_for_anchor($anchor->get_reference(), 0, 20, 'compact');
}
// ensure we are producing some text
if (is_array($output)) {
// the command to list all files
if (count($output)) {
$output = array_merge($output, array(Files::get_url($anchor->get_reference(), 'list') => i18n::s('All files')));
}
$output =& Skin::build_list($output, 'compact');
}
// actual transmission except on a HEAD request
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
echo $output;
}
// the post-processing hook, then exit
finalize_page(TRUE);
示例14: layout
//.........这里部分代码省略.........
$label = $label[1];
}
$content[] = $sub_prefix . $label . $sub_suffix;
}
}
// regular rendering of related articles
} else {
if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
$order = $matches[1];
} else {
$order = 'edition';
}
if ($related =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, $maximum_items - count($content), 'compact')) {
foreach ($related as $sub_url => $label) {
$sub_prefix = $sub_suffix = $sub_hover = '';
if (is_array($label)) {
$sub_prefix = $label[0];
$sub_suffix = $label[2];
if (@$label[5]) {
$sub_hover = $label[5];
}
$label = $label[1];
}
$content[] = $sub_prefix . $label . $sub_suffix;
}
}
}
}
// info on related files
if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
$related_count += $count;
// add related files if necessary
if (count($content) < $maximum_items && ($related = Files::list_by_date_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact'))) {
foreach ($related as $sub_url => $label) {
$sub_prefix = $sub_suffix = $sub_hover = '';
if (is_array($label)) {
$sub_prefix = $label[0];
$sub_suffix = $label[2];
if (@$label[5]) {
$sub_hover = $label[5];
}
$label = $label[1];
}
$content[] = $sub_prefix . $label . $sub_suffix;
}
}
}
// info on related links
if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
$related_count += $count;
// add related links if necessary
if (count($content) < $maximum_items && ($related = Links::list_by_date_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact'))) {
foreach ($related as $sub_url => $label) {
$sub_prefix = $sub_suffix = $sub_hover = '';
if (is_array($label)) {
$sub_prefix = $label[0];
$sub_suffix = $label[2];
if (@$label[5]) {
$sub_hover = $label[5];
}
$label = $label[1];
}
$content[] = $sub_prefix . $label . $sub_suffix;
}
示例15: elseif
// not found
if (!isset($item['id'])) {
include '../error.php';
// permission denied
} elseif (!$permitted) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation.'));
// package the files
} else {
// build a zip archive
include_once '../shared/zipfile.php';
$zipfile = new zipfile();
// get related files from the database
$items = array();
if (isset($type) && isset($id)) {
$items = Files::list_by_date_for_anchor($type . ':' . $id, 0, 20, 'raw');
}
// archive each file
$file_path = $context['path_to_root'] . Files::get_path($type . ':' . $id);
foreach ($items as $id => $attributes) {
// read file content
if ($content = Safe::file_get_contents($file_path . '/' . $attributes['file_name'], 'rb')) {
// add the binary data
$zipfile->deflate($attributes['file_name'], Safe::filemtime($file_path . '/' . $attributes['file_name']), $content);
}
}
//
// transfer to the user agent
//
// send the archive content
if ($archive = $zipfile->get()) {