本文整理汇总了PHP中Files::get_icon_url方法的典型用法代码示例。如果您正苦于以下问题:PHP Files::get_icon_url方法的具体用法?PHP Files::get_icon_url怎么用?PHP Files::get_icon_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Files
的用法示例。
在下文中一共展示了Files::get_icon_url方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: layout
/**
* list files
*
* @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 = '';
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// initialize variables
$prefix = $suffix = $icon = '';
// more details
$url = Files::get_permalink($item);
// codes
$codes = array();
// files that can be embedded
if (preg_match('/\\.(3gp|flv|gan|m4v|mm|mov|mp4|swf)$/i', $item['file_name'])) {
$codes[] = '[embed=' . $item['id'] . ']';
}
// link for direct download
$codes[] = '[file=' . $item['id'] . ']';
$codes[] = '[download=' . $item['id'] . ']';
// integrate codes
if (!isset($_SESSION['surfer_editor']) || $_SESSION['surfer_editor'] == 'yacs') {
foreach ($codes as $code) {
$suffix .= '<a onclick="edit_insert(\'\', \' ' . $code . '\');return false;" title="insert" tabindex="2000">' . $code . '</a> ';
}
} else {
$suffix .= join(' ', $codes);
}
$suffix .= BR . '<span class="details">';
// signal restricted and private files
if ($item['active'] == 'N') {
$suffix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$suffix .= RESTRICTED_FLAG;
}
// file title or file name
$label = Codes::beautify_title($item['title']);
if (!$label) {
$label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
}
$suffix .= $label;
// flag files uploaded recently
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
$suffix .= '</span>';
// details
$details = array();
if (Surfer::is_logged() && $item['edit_name']) {
$details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
}
// the menu bar for associates and poster
if (Surfer::is_empowered()) {
$details[] = Skin::build_link($url, i18n::s('details'), 'basic');
$details[] = Skin::build_link(Files::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic');
$details[] = Skin::build_link(Files::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic');
}
// append details
if (count($details)) {
$suffix .= BR . Skin::finalize_list($details, 'menu');
}
// explicit icon
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
} else {
$icon = $context['url_to_root'] . Files::get_icon_url($item['file_name']);
}
// list all components for this item
$items[$url] = array($prefix, '_', $suffix, 'file', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例3: preview
/**
* give a preview of file rendering
* used after ajax uploading in forms
*
* @param string $url string where is the file
* @param string $input_name the input that what used to upload
*/
public static function preview($url, $input_name)
{
global $context;
// get file ext.
$ext = pathinfo($url, PATHINFO_EXTENSION);
$basename = basename($url);
// at least show file's name
$preview = $basename;
// destroy link, put it where you want
$destroy = '<a class="yc-upload-destroy" data-del="' . $input_name . '" href="javascript:void(0);" title="' . i18n::s('Delete') . '" onclick="Yacs.uploadDestroy($(this).data(\'del\'),$(this))" >x</a>' . "\n";
// file is a image
if (Files::is_image($url) && ($image_information = Safe::GetImageSize($url))) {
// make a temp thumb name
$thumb = uniqid() . '.' . $ext;
$thumbpath = $context['path_to_root'] . UPLOAD_PATH . $thumb;
$thumburl = $context['url_to_root'] . UPLOAD_PATH . $thumb;
// make a thumb
Image::shrink($url, $thumbpath, true);
// build image
$preview = Skin::build_image('left', $thumburl, '') . '<span style="line-height:34px"> ' . $basename . '</span>' . "\n" . $destroy;
} else {
// file is a reconnized audio format
switch ($ext) {
case 'mp3':
case 'm4a':
case 'aac':
case 'oog':
// audio file
$audio_url = $context['url_to_root'] . UPLOAD_PATH . $basename;
$preview .= $destroy . BR . Skin::build_audioplayer($audio_url);
break;
default:
$icon = Skin::build_image('inline', $context['url_to_master'] . $context['url_to_root'] . Files::get_icon_url($basename), $basename);
$preview = $icon . $preview . ' ' . $destroy;
break;
}
}
// add separator
$preview .= '<hr class="clear" />' . "\n";
// wrap
$preview = '<div class="yc-preview">' . $preview . '</div>';
return $preview;
}
示例4: sprintf
case 'xlsx':
$description .= '<p>' . sprintf(i18n::s('You are about to download a Microsoft Excel document. If you do not have this software, you may download a free vizualiser from %s. Or you may prefer to use the free office solution from the %s.'), Skin::build_link(i18n::s('www.microsoft.com'), i18n::s('Microsoft web server'), 'external'), Skin::build_link(i18n::s('www.openoffice.org'), i18n::s('Open Office web server'), 'external')) . '</p>';
break;
default:
$description .= '';
break;
}
// the download link
$link = $context['url_to_root'] . Files::get_url($item['id'], 'fetch', $item['file_name']);
// hovering the link
$title = i18n::s('Get a copy of this file');
// a clickable thumbnail to download the file
// if(isset($item['thumbnail_url']) && $item['thumbnail_url'])
// $icon = '<img src="'.$item['thumbnail_url'].'" alt="" />';
// else
$icon = '<img src="' . $context['url_to_root'] . Files::get_icon_url($item['file_name']) . '" alt="" />';
// file is available to download
Skin::define_img('DOWNLOAD_IMG', 'files/download.gif');
$label = '<a href="' . $link . '" title="' . encode_field($title) . '" id="file_download">' . $icon . ' ' . sprintf(i18n::s('Download %s'), str_replace('_', ' ', $item['file_name'])) . '</a>';
// use a definition list to enable customization of the download box
$context['text'] .= '<dl class="download">' . '<dt>' . $label . '</dt>' . '<dd>' . $description . '</dd></dl>' . "\n";
// alternate link, if any
if (isset($item['alternate_href']) && $item['alternate_href']) {
// ed2k
if (preg_match('/^ed2k:\\/\\//', $item['alternate_href'])) {
$context['text'] .= '<p>' . sprintf(i18n::s('If you have installed some Overnet, Emule, or Edonkey client software, you may prefer click on the following ed2k link: %s'), Skin::build_link($item['alternate_href'], i18n::s('Download from peers'), 'external')) . '</p>' . "\n";
} elseif (preg_match('/\\.torrent$/', $item['alternate_href'])) {
$context['text'] .= '<p>' . sprintf(i18n::s('If you have installed some BitTorrent client software, you may prefer click on the following torrent link: %s'), Skin::build_link($item['alternate_href'], i18n::s('Download from peers'), 'external')) . '</p>' . "\n";
} else {
$context['text'] .= '<p>' . sprintf(i18n::s('You may prefer to use the following link: %s'), Skin::build_link($item['alternate_href'], 'Alternate link', 'external')) . '</p>' . "\n";
}
示例5: 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
//.........这里部分代码省略.........