本文整理汇总了PHP中Codes::render_object方法的典型用法代码示例。如果您正苦于以下问题:PHP Codes::render_object方法的具体用法?PHP Codes::render_object怎么用?PHP Codes::render_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Codes
的用法示例。
在下文中一共展示了Codes::render_object方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: layout
/**
* list files
*
* Recognize following variants:
* - 'section:123' to list items attached to one particular anchor
* - 'no_author' to list items attached to one user profile
*
* @param resource the SQL result
* @return string HTML text to be displayed, or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// sanity check
if (!isset($this->focus)) {
$this->focus = '';
}
// process all items in the list
$items = array();
while ($item = SQL::fetch($result)) {
// one box at a time
$box = '';
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// we feature only the head of the list, if we are at the origin page
if (!count($items) && $anchor && is_string($this->focus) && $this->focus == $anchor->get_reference()) {
$box .= Codes::render_object('file', $item['id']);
// no side icon
$icon = '';
// we are listing various files from various places
} else {
$prefix = $suffix = '';
// stream the file
if (Files::is_stream($item['file_name'])) {
$url = Files::get_url($item['id'], 'stream', $item['file_name']);
} else {
$url = Files::get_url($item['id'], 'fetch', $item['file_name']);
}
// absolute url
$url = $context['url_to_home'] . $context['url_to_root'] . $url;
// signal restricted and private files
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// file title or file name
$label = Codes::beautify_title($item['title']);
if (!$label) {
$label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
}
// show a reference to the file for members
$hover = i18n::s('Get the file');
if (Surfer::is_member()) {
$hover .= ' [file=' . $item['id'] . ']';
}
// flag files uploaded recently
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
// one line of text
$box .= $prefix . Skin::build_link($url, $label, 'basic', $hover) . $suffix;
// side icon
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
} else {
$icon = $context['url_to_root'] . Files::get_icon_url($item['file_name']);
}
// build the complete HTML element
$icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($label)) . '" />';
// make it a clickable link
$icon = Skin::build_link($url, $icon, 'basic');
}
// first line of details
$details = array();
// file poster and last action
if ($this->layout_variant != 'no_author') {
$details[] = sprintf(i18n::s('shared by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
} else {
$details[] = Skin::build_date($item['edit_date']);
}
// downloads
if ($item['hits'] > 1) {
$details[] = Skin::build_number($item['hits'], i18n::s('downloads'));
}
// file size
if ($item['file_size'] > 1) {
$details[] = Skin::build_number($item['file_size'], i18n::s('bytes'));
}
// anchor link
//.........这里部分代码省略.........
示例2: sprintf
$compact_list = Skin::build_list(Files::list_for_anchor_and_name($anchor->get_reference(), $uploaded, 'compact'), 'compact');
$context['text'] .= '<p>' . i18n::s('Following files have been added:') . '</p>' . $compact_list;
// log multiple upload
$label = sprintf(i18n::c('New files in %s'), strip_tags($anchor->get_title()));
Logger::notify('files/edit.php: ' . $label, $compact_list);
// push the list of uploaded files to the notification
$attributes = array();
$attributes['message'] = '<p>' . i18n::s('Following files have been added:') . '</p>' . $compact_list;
$attributes['anchor'] = $anchor->get_reference();
// notification to send by e-mail
$mail = array();
$mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Contribution'), strip_tags($anchor->get_title()));
$mail['notification'] = Files::build_notification('multiple', $attributes);
// one file has been added
} elseif ($item =& Files::get_by_anchor_and_name($anchor->get_reference(), $uploaded)) {
$context['text'] .= '<p>' . i18n::s('Following file has been added:') . '</p>' . Codes::render_object('file', $item['id']);
// use this file record
$_REQUEST['id'] = $item['id'];
// log single upload
$label = sprintf(i18n::c('New file in %s'), strip_tags($anchor->get_title()));
$link = Files::get_permalink($item);
$description = sprintf(i18n::c('%s at %s'), $item['file_name'], '<a href="' . $link . '">' . $link . '</a>');
Logger::notify('files/edit.php: ' . $label, $description);
// notification to send by e-mail
$mail = array();
$mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Contribution'), strip_tags($anchor->get_title()));
$mail['notification'] = Files::build_notification('upload', $item);
}
// send to anchor watchers
if (isset($_REQUEST['notify_watchers']) && $_REQUEST['notify_watchers'] == 'Y') {
$anchor->alert_watchers($mail, $action, isset($_REQUEST['active']) && $_REQUEST['active'] == 'N');
示例3: elseif
} elseif (isset($context['users_with_auto_publish']) && $context['users_with_auto_publish'] == 'Y' || is_object($anchor) && $anchor->has_option('auto_publish')) {
$context['text'] .= i18n::s('<p>Don\'t forget to publish the new page someday. Review the page, enhance it and then click on the Publish command to make it publicly available.</p>');
} else {
$context['text'] .= i18n::s('<p>The new page will now be reviewed before its publication. It is likely that this will be done within the next 24 hours at the latest.</p>');
}
if (!isset($_REQUEST['first_comment'])) {
$_REQUEST['first_comment'] = '';
}
// attach some file
$file_path = Files::get_path('article:' . $_REQUEST['id']);
if (isset($_FILES['upload']) && ($uploaded = Files::upload($_FILES['upload'], $file_path, 'article:' . $_REQUEST['id']))) {
// several files have been added
if (is_array($uploaded)) {
$_REQUEST['first_comment'] .= '<div>' . Skin::build_list(Files::list_for_anchor_and_name('article:' . $_REQUEST['id'], $uploaded, 'compact'), 'compact') . '</div>';
} elseif ($file =& Files::get_by_anchor_and_name('article:' . $_REQUEST['id'], $uploaded)) {
$_REQUEST['first_comment'] .= '<div>' . Codes::render_object('file', $file['id']) . '</div>';
// silently delete the previous file if the name has changed
if (isset($file['file_name']) && $file['file_name'] != $uploaded) {
Safe::unlink($file_path . '/' . $file['file_name']);
}
}
}
// capture first comment too
if (isset($_REQUEST['first_comment']) && $_REQUEST['first_comment']) {
include_once $context['path_to_root'] . 'comments/comments.php';
$fields = array();
$fields['anchor'] = 'article:' . $_REQUEST['id'];
$fields['description'] = $_REQUEST['first_comment'];
Comments::post($fields);
}
// post an overlay, with the new article id --don't stop on error
示例4: upload_to
/**
* upload a file as a image attach to a given anchor
* to be used in custom "edit_as" script
*
* @global string $context
* @param object $anchor
* @param array $file (from $_FILES)
* @param bool $set_as_thumb
* @param bool $put
*/
public static function upload_to($anchor, $file, $set_as_thumb = false, $put = false)
{
global $context;
// attach some image
$path = Files::get_path($anchor->get_reference(), 'images');
// $_REQUEST['action'] = 'set_as_icon'; // instruction for image::upload
if (isset($file) && ($uploaded = Files::upload($file, $path, array('Image', 'upload')))) {
// prepare image informations
$image = array();
$image['image_name'] = $uploaded;
$image['image_size'] = $file['size'];
$image['thumbnail_name'] = 'thumbs/' . $uploaded;
$image['anchor'] = $anchor->get_reference();
//$combined = array_merge($image, $_FILES);
// post the image which was uploaded
if ($image['id'] = Images::post($image)) {
// successfull post
$context['text'] .= '<p>' . i18n::s('Following image has been added:') . '</p>' . Codes::render_object('image', $image['id']) . '<br style="clear:left;" />' . "\n";
// set image as icon and thumbnail
if ($set_as_thumb) {
// delete former icon if any
/*if(isset($anchor->item['icon_url'])
&& $anchor->item['icon_url']
&& $match = Images::get_by_anchor_and_name($anchor->get_reference(), pathinfo($anchor->item['icon_url'],PATHINFO_BASENAME))) {
if($match['id'] != $image['id'])
Images::delete($match['id']);
}*/
$fields = array('thumbnail_url' => Images::get_thumbnail_href($image), 'icon_url' => Images::get_icon_href($image));
if ($put) {
$fields['id'] = $_REQUEST['id'];
$class = $anchor->get_static_group_class();
$class::put_attributes($fields);
} else {
$_REQUEST = array_merge($_REQUEST, $fields);
}
}
}
}
}