本文整理汇总了PHP中CKunenaTools::shortenFileName方法的典型用法代码示例。如果您正苦于以下问题:PHP CKunenaTools::shortenFileName方法的具体用法?PHP CKunenaTools::shortenFileName怎么用?PHP CKunenaTools::shortenFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKunenaTools
的用法示例。
在下文中一共展示了CKunenaTools::shortenFileName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: browseUploaded
function browseUploaded($option, $attachments, $type)
{
$kunena_db =& JFactory::getDBO();
$map = JPATH_ROOT;
?>
<script language="javascript" type="text/javascript">
<!--
function decision(message, url)
{
if (confirm(message))
location.href = url;
}
//-->
</script>
<div class="kadmin-functitle icon-<?php
echo $type ? 'images' : 'files';
?>
">
<?php
echo $type ? JText::_('COM_KUNENA_A_IMGB_IMG_BROWSE') : JText::_('COM_KUNENA_A_IMGB_FILE_BROWSE');
?>
</div>
<table class="adminform">
<tr>
<td>
<?php
echo $type ? JText::_('COM_KUNENA_A_IMGB_TOTAL_IMG') : JText::_('COM_KUNENA_A_IMGB_TOTAL_FILES') . ': ' . count($attachments);
?>
</td>
</tr>
<tr>
<td>
<?php
echo $type ? JText::_('COM_KUNENA_A_IMGB_ENLARGE') : JText::_('COM_KUNENA_A_IMGB_DOWNLOAD');
?>
</td>
</tr>
</table>
<?php
if (!empty($attachments)) {
?>
<table class="adminform">
<tr>
<?php
$i = 0;
foreach ($attachments as $attachment) {
$i++;
$filename = $attachment->filename;
$attach_live_path = JURI::root() . '/' . $attachment->folder . '/' . $attachment->filename;
$attach_path = JPATH_ROOT . '/' . $attachment->folder . '/' . $attachment->filename;
?>
<td>
<table style="border: 1px solid #ccc;">
<tr>
<td height="90" width="130" style="text-align: center">
<?php
echo $type ? '<a href="' . kescape($attach_live_path) . '" target="_blank" title="' . JText::_('COM_KUNENA_A_IMGB_ENLARGE') . '">
<img src="' . kescape($attach_live_path) . '" width="80" height="80" border="0" alt="" /></a>' : '<a href="' . kescape($attach_live_path) . '" title="' . JText::_('COM_KUNENA_A_IMGB_DOWNLOAD') . '">
<img src="../administrator/components/com_kunena/images/kfile.png" border="0" alt="" /></a>';
?>
</td>
</tr>
<tr>
<td style="text-align: center">
<br />
<strong><?php
echo JText::_('COM_KUNENA_A_IMGB_NAME');
?>
: </strong>
<?php
echo kescape(CKunenaTools::shortenFileName($filename, 10, 15));
?>
<br />
<?php
if (is_file($attach_path)) {
?>
<strong><?php
echo JText::_('COM_KUNENA_A_IMGB_SIZE');
?>
: </strong> <?php
echo @filesize($attach_path) . ' ' . JText::_('COM_KUNENA_A_IMGB_WEIGHT');
?>
<br />
<?php
$type ? list($width, $height) = @getimagesize($attach_path) : '';
echo $type ? '<strong>' . JText::_('COM_KUNENA_A_IMGB_DIMS') . ': </strong> ' . $width . 'x' . $height . '<br />' : '';
}
echo $type ? '<a href="javascript:decision(\'' . JText::_('COM_KUNENA_A_IMGB_CONFIRM') . '\',\'index.php?option=' . $option . '&task=deleteImage&id=' . $attachment->id . '\')">' . JText::_('COM_KUNENA_A_IMGB_REMOVE') . '</a><br />' : '<a href="javascript:decision(\'' . JText::_('COM_KUNENA_A_IMGB_CONFIRM') . '\',\'index.php?option=' . $option . '&task=deleteFile&id=' . kescape($attachment->id) . '\')">' . JText::_('COM_KUNENA_A_IMGB_REMOVE') . '</a><br />';
if ($attachment->catid > 0) {
echo '<a href="../index.php?option=' . $option . '&func=view&catid=' . kescape($attachment->catid) . '&id=' . kescape($attachment->mesid) . '#' . kescape($attachment->mesid) . '" target="_blank">' . JText::_('COM_KUNENA_A_IMGB_VIEW') . '</a>';
} else {
echo JText::_('COM_KUNENA_A_IMGB_NO_POST');
}
?>
</td>
</tr>
</table>
</td>
<?php
if (!fmod($i, 5)) {
//.........这里部分代码省略.........
示例2: _get
function _get($attachments)
{
$ret = array();
foreach ($attachments as $attachment) {
// combine all images into one type
$attachment->shorttype = $this->isImage($attachment->filetype) ? 'image' : $attachment->filetype;
$attachment->shortname = CKunenaTools::shortenFileName($attachment->filename);
switch (strtolower($attachment->shorttype)) {
case 'image':
// Check for thumbnail and if available, use for display
if (file_exists(JPATH_ROOT . '/' . $attachment->folder . '/thumb/' . $attachment->filename)) {
$thumb = $attachment->folder . '/thumb/' . $attachment->filename;
$imgsize = '';
} else {
$thumb = $attachment->folder . '/' . $attachment->filename;
$imgsize = 'width="' . $this->_config->thumbwidth . 'px" height="' . $this->_config->thumbheight . 'px"';
}
$img = '<img title="' . $this->escape($attachment->filename) . '" ' . $imgsize . ' src="' . JURI::ROOT() . $thumb . '" alt="' . $this->escape($attachment->filename) . '" />';
$attachment->thumblink = CKunenaLink::GetAttachmentLink($this->escape($attachment->folder), $this->escape($attachment->filename), $img, $this->escape($attachment->filename), $this->_config->lightbox ? 'lightbox[thumb' . intval($attachment->mesid) . ']' : '');
$img = '<img title="' . $this->escape($attachment->filename) . '" src="' . JURI::ROOT() . $this->escape($attachment->folder) . '/' . $this->escape($attachment->filename) . '" alt="' . $this->escape($attachment->filename) . '" />';
$attachment->imagelink = CKunenaLink::GetAttachmentLink($this->escape($attachment->folder), $this->escape($attachment->filename), $img, $this->escape($attachment->filename), $this->_config->lightbox ? 'lightbox[imagelink' . intval($attachment->mesid) . ']' : '');
$attachment->textLink = CKunenaLink::GetAttachmentLink($this->escape($attachment->folder), $this->escape($attachment->filename), $this->escape($attachment->shortname), $this->escape($attachment->filename), $this->_config->lightbox ? 'lightbox[simple' . $attachment->mesid . ']' . ' nofollow' : ' nofollow') . ' (' . number_format(intval($attachment->size) / 1024, 0, '', ',') . 'KB)';
break;
default:
// Filetype without thumbnail or icon support - use default file icon
$img = '<img src="' . KUNENA_URLICONSPATH . 'attach_generic.png" alt="' . JText::_('COM_KUNENA_ATTACH') . '" />';
$attachment->thumblink = CKunenaLink::GetAttachmentLink($this->escape($attachment->folder), $this->escape($attachment->filename), $img, $this->escape($attachment->filename), 'nofollow');
$attachment->textLink = CKunenaLink::GetAttachmentLink($this->escape($attachment->folder), $this->escape($attachment->filename), $this->escape($attachment->shortname), $this->escape($attachment->filename), 'nofollow') . ' (' . number_format(intval($attachment->size) / 1024, 0, '', ',') . 'KB)';
}
$attachment->disabled = false;
if (!$this->_my->id) {
if ($attachment->shorttype == 'image' && !$this->_config->showimgforguest) {
$attachment->disabled = true;
$attachment->textLink = JText::_('COM_KUNENA_SHOWIMGFORGUEST_HIDEIMG');
}
if ($attachment->shorttype != 'image' && !$this->_config->showfileforguest) {
$attachment->disabled = true;
$attachment->textLink = JText::_('COM_KUNENA_SHOWIMGFORGUEST_HIDEFILE');
}
if ($attachment->disabled) {
$attachment->thumblink = '<img src="' . KUNENA_URLICONSPATH . 'attach_generic.png" alt="' . JText::_('COM_KUNENA_ATTACH') . '" />';
unset($attachment->imagelink);
$attachment->size = 0;
}
}
$this->_instances[$attachment->id] = $attachment;
$ret[$attachment->mesid][$attachment->id] = $attachment;
}
return $ret;
}