20,398
社区成员




{foreach $items as $item}
{strip}
。。。。。。。。。。。。。。
。。。。。。。。。。。。。。
{if $item->kind == "folder"}
<td class="name"><p><a href="/Views/Regions/{$item->id}">{$item->name}</a></p></td>
{elseif $item->type != "link"}
<td class="name"><p><a href="/Regions/Files/Download/{$item->id}">{$item->name}</a></p></td>
{else}
{$link_content=""}
{$this_id=$item->id}
{$search_link_query="select * from archive.file where id='$this_id'"}
{$con = mysqli_connect("localhost","root","root")}
{$result = mysqli_query($con,$search_link_query)}
{mysqli_close($con)}
{$row=mysqli_fetch_row($result)}
{$link_content=$row[8]}
<td class="name"><p><a href="{$link_content}" target="_blank">{$item->name}</a></p></td>
{/if}
........................
...........................
{/strip}
{/foreach}
<?php
load_module("folders");
load_module("files");
//该页面的基本功能就是在表格中显示某个区域里的文件或者文件夹,我要增加一个链接link,并且其他一些链接等功能
$id = getParamStr("id"); //此处id应该是这表格所属区域的Id,与我的问题相联系的数据库中储存的文件或链接id不一样,这个是我的理解,我也是刚看这代码
if ($action == "search") //对这个页面有两个动作,一个是search
{
$search = postParamStr("search");
$folders = do_action("folders","search", array($search, $currentUser->allowedRegion));
$files = do_action("files","search", array($search, $currentUser->allowedRegion));
$smarty->assign("folder", NULL);
$paths = array("Search Result");
$path = new stdClass();
$path->id = NULL;
$path->name = "Search Result";
$smarty->assign("paths", array($path));
}
else //对这个页面的另一动作是正常显示
{
$folders = list_items("folders", $id);
$folder = get_item("folders", $id);
$files = list_items("files", $id);
$smarty->assign("folder",$folder);
$paths = $folder->path;
if ($currentUser->level == 2)
{
unset($paths[0]);
$paths = array_values($paths);
}
$smarty->assign("paths", $paths);
}
$items = array_merge($folders,$files); //获取到显示记录,并把多个记录组合起来
$items = sort_items($items); //排序功能
$smarty->assign("items", $items);
$smarty->assign("action", $action);
$smarty->display("folders.tpl");
?>
前端的代码太多,我还是截取循环的那部分,供参考:
{if count($items) > 0}
{foreach $items as $item}
{strip}
<tr class="light" style="display:table-row;border-bottom:1px solid #DADAE3;" id="{$item->id}">
{if $item->kind == "folder"}
<td class="type"><p><img src="/Images/iconset/Folder2.png" title="folder"/></p></td>
{else}
{if $item->type == "docx" || $item->type == "doc"}
<td class="type"><p><img src="/Images/iconset/page_white_word.png" title="word document"/></p></td>
{else if $item->type == "xlsx" || $item->type == "xls"}
<td class="type"><p><img src="/Images/iconset/page_white_excel.png" title="excel document"/></p></td>
{elseif $item->type == "pdf"}
<td class="type"><p><img src="/Images/iconset/page_white_acrobat.png" title="PDF"/></p></td>
{elseif $item->type == "png" || $item->type == "gif" || $item->type == "jpg"}
<td class="type"><p><img src="/Images/iconset/picture.png" title="png"/></p></td>
{elseif $item->type == "ppt" || $item->type == "pptx"}
<td class="type"><p><img src="/Images/iconset/page_white_powerpoint.png" title="powerpoint document"/></p></td>
{elseif $item->type == "mp4"}
<td class="type"><p><img src="/Images/iconset/film.png" title="movie"/></p></td>
{elseif $item->type == "link"}
<td class="type"><p><img src="/Images/iconset/link.png" title="link"/></p></td>
{else}
<td class="type"><p><img src="/Images/iconset/page_white.png" title="document"/></p></td>
{/if}
{/if}
{if $item->kind == "folder"}
<td class="name"><p><a href="/Views/Regions/{$item->id}">{$item->name}</a></p></td>
{elseif $item->type != "link"}
<td class="name"><p><a href="/Regions/Files/Download/{$item->id}">{$item->name}</a></p></td>
{else}
{$link_content=""}
{$this_id=$item->id}
{$search_link_query="select * from archive.file where id='$this_id'"}
{$con = mysqli_connect("localhost","root","goldmine")}
{$result = mysqli_query($con,$search_link_query)}
{mysqli_close($con)}
{$row=mysqli_fetch_row($result)}
{$link_content=$row[8]}
<td class="name"><p><a href="{$link_content}" target="_blank">{$item->name}</a></p></td>
{/if}
<td class="creator"><p>{$item->createdByName}</p></td>
<td class="created"><p>{$item->created}</p></td>
<td class="modified"><p>{$item->lastUpdated}</p></td>
<td class="visibility"><p>Visible</p></td>
<td class="size"><p>{if $item->size > 1000}
{round(($item->size / 1024), 1)}MB
{else}
{$item->size}KB</p></td>
{/if}</p></td>
{if $item->kind == "folder"}
<td class="id" align="middle"><p><a href="JavaScript:void(0);" onclick="return popitup('/Views/Folders/{$item->id}/Move')"><img src="/Images/iconset/move.png" style="width:18px;" /></a></p></td>
{elseif $item->kind == "file"}
<td class="id" align="middle"><p><a href="JavaScript:void(0);" onclick="return popitup('/Views/Files/{$item->id}/Move')"><img src="/Images/iconset/move.png" style="width:18px;" /></a></p></td>
{/if}
{if $item->kind == "folder"}
<td class="edit"><p><a href="/Views/Folders/Edit/{$item->id}"><img src="/Images/iconset/wrench2.png" width="16px" title="edit"/></a></p></td>
{elseif $item->kind == "file"}
<td class="edit"><p><a href="/Views/Files/Edit/{$item->id}"><img src="/Images/iconset/wrench2.png" width="16px" title="edit"/></a></p></td>
{/if}
<td class="remove"><p><a href="/Views/Folders/Delete/{$item->id}"
{if $item->kind == "folder"}
{if $item->folderCount > 0 || $item->fileCount > 0}
onclick="JavaScript:return confirm('This folder is not empty. If you delete it all content will also be deleted. Do you still want to continue?');"><img src="/Images/iconset/cross.png" width="16px" title="delete"></a></p></td>
{else}
onclick="JavaScript:return confirm('Do you really want to delete this folder?');"><img src="/Images/iconset/cross.png" width="16px" title="delete"></a></p></td>
{/if}
{elseif $item->kind == "file"}
<td class="remove"><p><a href="/Views/Files/Delete/{$item->id}" onclick="JavaScript:return confirm('Do you really want to delete this file?');"><img src="/Images/iconset/cross.png" width="16px"/ title="delete"></a></p></td>
{/if}
</tr>
{/strip}
{/foreach}
{else}
<tr><td colspan="10"><table>
<tr valign="middle" >
<td class="light">
{if $action != "search"}
<img src="/Images/emptyfolder.png" width="130px"/>
{/if}
</td>
<td class="light">
{if $action == "search"}
<br />
<h1>No files or folders could be found!</h1>
{else}
<h1>This folder is empty!</h1>
{/if}