本文整理汇总了PHP中Files::is_stream方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::is_stream方法的具体用法?PHP Files::is_stream怎么用?PHP Files::is_stream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Files
的用法示例。
在下文中一共展示了Files::is_stream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rawurlencode
if (is_object($anchor)) {
$context['text'] .= $anchor->get_prefix();
}
// if we have a local file
if (!isset($item['file_href']) || !$item['file_href']) {
// where the file is
$path = $context['path_to_root'] . Files::get_path($item['anchor']) . '/' . rawurlencode(utf8::to_ascii($item['file_name']));
//load some file parser if one is available
$analyzer = NULL;
if (is_readable($context['path_to_root'] . 'included/getid3/getid3.php')) {
include_once $context['path_to_root'] . 'included/getid3/getid3.php';
$analyzer = new getid3();
}
// parse file content, and streamline information
$data = array();
if (is_object($analyzer) && Files::is_stream($item['file_name'])) {
$data = $analyzer->analyze($path);
getid3_lib::CopyTagsToComments($data);
}
// details
$rows = array();
// artist
if ($value = @implode(' & ', @$data['comments_html']['artist'])) {
$rows[] = array(i18n::s('Artist'), $value);
}
// title
if ($value = @implode(', ', @$data['comments_html']['title'])) {
$rows[] = array(i18n::s('Title'), $value);
}
// genre
if ($value = @implode(', ', @$data['comments_html']['genre'])) {
示例2: 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
//.........这里部分代码省略.........
示例3: layout
/**
* list files 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
while ($item = SQL::fetch($result)) {
// one box at a time
$box = '';
// get the main anchor
$anchor = Anchors::get($item['anchor']);
$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
$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']));
// 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'));
}
// file has been detached
if (isset($item['assign_id']) && $item['assign_id']) {
// who has been assigned?
if (Surfer::is($item['assign_id'])) {
$details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by you %s'), Skin::build_date($item['assign_date']));
} else {
$details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by %s %s'), Users::get_link($item['assign_name'], $item['assign_address'], $item['assign_id']), Skin::build_date($item['assign_date']));
}
}
// the main anchor link
if (is_object($anchor)) {
$details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'article'));
}
// append details
if (count($details)) {
$box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
}
// layout this item
if ($icon) {
$list = array(array($box, $icon));
$items[] = array($item['score'], Skin::finalize_list($list, 'decorated'));
// put the item in a division
//.........这里部分代码省略.........