本文整理汇总了PHP中WPFB_Core::SetFileTpls方法的典型用法代码示例。如果您正苦于以下问题:PHP WPFB_Core::SetFileTpls方法的具体用法?PHP WPFB_Core::SetFileTpls怎么用?PHP WPFB_Core::SetFileTpls使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPFB_Core
的用法示例。
在下文中一共展示了WPFB_Core::SetFileTpls方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Display
static function Display()
{
wpfb_loadclass('Output', 'File', 'Category', 'TplLib');
$content = '';
$file_tpls = WPFB_Core::GetTpls('file');
$cat_tpls = WPFB_Core::GetTpls('cat');
if (true || !isset($file_tpls['filebrowser_admin'])) {
$file_tpls['filebrowser_admin'] = '%file_small_icon% ' . '%file_display_name% (%file_size%) ' . '<!-- IF %file_user_can_edit% --><a href="%file_edit_url%" class="edit" onclick="wpfbFBEditFile(event)">%\'Edit\'%</a><!-- ENDIF -->' . '<!-- IF %file_user_can_edit% --><a href="#" class="delete" onclick="return confirm(\'Sure?\') && wpfbFBDelete(event) && false;">%\'Delete\'%</a><!-- ENDIF -->';
WPFB_Core::SetFileTpls($file_tpls);
//WPFB_Admin::ParseTpls();
}
if (true || !isset($cat_tpls['filebrowser_admin'])) {
$cat_tpls['filebrowser_admin'] = '<span class="cat-icon" style="background-image:url(\'%cat_icon_url%\');"><span class="cat-icon-overlay"></span></span>' . '%cat_name% ' . '<!-- IF %cat_user_can_edit% --><a href="%cat_edit_url%" class="edit" onclick="wpfbFBEditCat(event)">%\'Edit\'%</a><!-- ENDIF -->' . '<!-- IF %cat_user_can_edit% --><a href="#" class="delete" onclick="return confirm(\'Sure?\') && wpfbFBDelete(event) && false;">%\'Delete\'%</a><!-- ENDIF -->';
WPFB_Core::SetCatTpls($cat_tpls);
WPFB_Admin::ParseTpls();
}
WPFB_Output::FileBrowser($content, 0, empty($_GET['wpfb_cat']) ? 0 : intval($_GET['wpfb_cat']));
WPFB_Core::PrintJS();
?>
<div class="wrap filebrowser-admin">
<h2><?php
_e('File Browser', 'wp-filebase');
?>
</h2>
<?php
echo '<div>' . __('You can Drag & Drop (multiple) files directly on Categories to upload them. Dragging a category or an existing file to another category is also possible.', 'wp-filebase') . '</div>';
echo $content;
?>
</div>
<script>
function wpfbFBEditCat(e) {
e.stopPropagation();
}
function wpfbFBEditFile(e) {
e.stopPropagation();
}
function wpfbFBDelete(e) {
e.stopPropagation();
var t = jQuery(e.currentTarget).parents('li').first();
var d = {wpfb_action: 'delete'};
var tid = t.attr('id').split('-');
d[tid[tid.length-2]+'_id'] = +tid[tid.length-1];
jQuery.ajax({type: 'POST', url: wpfbConf.ajurl, data: d,
//async: false,
success: (function (data) {
if (data == '1') {
t.fadeOut(300, function() { t.remove(); });
}
})
});
return false;
}
</script>
<?php
}
示例2: Display
static function Display()
{
wpfb_loadclass('Output', 'File', 'Category', 'TplLib');
$content = '';
$file_tpls = WPFB_Core::GetTpls('file');
$cat_tpls = WPFB_Core::GetTpls('cat');
if (true || !isset($file_tpls['filebrowser_admin'])) {
$file_tpls['filebrowser_admin'] = '%file_small_icon% ' . '%file_display_name% (%file_size%) ' . '<!-- IF %file_user_can_edit% --><a href="%file_edit_url%" class="edit" onclick="wpfbFBEditFile(event)">%\'Edit\'%</a><!-- ENDIF -->';
WPFB_Core::SetFileTpls($file_tpls);
//WPFB_Admin::ParseTpls();
}
if (true || !isset($cat_tpls['filebrowser_admin'])) {
$cat_tpls['filebrowser_admin'] = '<span class="cat-icon" style="background-image:url(\'%cat_icon_url%\');"><span class="cat-icon-overlay"></span></span>' . '%cat_name% ' . '<!-- IF %cat_user_can_edit% --><a href="%cat_edit_url%" class="edit" onclick="wpfbFBEditCat(event)">%\'Edit\'%</a><!-- ENDIF -->';
WPFB_Core::SetCatTpls($cat_tpls);
WPFB_Admin::ParseTpls();
}
WPFB_Output::FileBrowser($content, 0, empty($_GET['wpfb_cat']) ? 0 : intval($_GET['wpfb_cat']));
WPFB_Core::PrintJS();
?>
<div class="wrap filebrowser-admin">
<h2><?php
_e('File Browser', WPFB);
?>
</h2>
<?php
echo '<div>' . __('You can Drag & Drop (multiple) files directly on Categories to upload them. Dragging a category or an existing file to another category is also possible.', WPFB) . '</div>';
echo $content;
?>
</div>
<script>
function wpfbFBEditCat(e) {
e.stopPropagation();
}
function wpfbFBEditFile(e) {
e.stopPropagation();
}
</script>
<?php
}
示例3: AddTpls
static function AddTpls($old_ver = null)
{
$def_tpls_file = array('filebrowser' => '%file_small_icon% <a href="%file_url%" title="Download %file_display_name%">%file_display_name%</a> (%file_size%)', 'download-button' => '<div style="text-align:center; width:250px; margin: auto; font-size:smaller;"><a href="%file_url%" class="wpfb-dlbtn"><div></div></a>
%file_display_name% (%file_size%, %file_hits% downloads)
</div>', 'image_320' => '[caption id="file_%file_id%" align="alignnone" width="320" caption="<!-- IF %file_description% -->%file_description%<!-- ELSE -->%file_display_name%<!-- ENDIF -->"]<img class="size-full" title="%file_display_name%" src="%file_url%" alt="%file_display_name%" width="320" />[/caption]' . "\n\n", 'thumbnail' => '<div class="wpfilebase-fileicon"><a href="%file_url%" title="Download %file_display_name%"><img align="middle" src="%file_icon_url%" /></a></div>' . "\n", 'simple' => '<p><img src="%file_icon_url%" style="height:20px;vertical-align:middle;" /> <a href="%file_url%" title="Download %file_display_name%">%file_display_name%</a> (%file_size%)</p>', '3-col-row' => '<tr><td><a href="%file_url%">%file_display_name%</a></td><td>%file_size%</td><td>%file_hits%</td></tr>', 'mp3' => '<div class="wpfilebase-attachment">
<div class="wpfilebase-fileicon"><a href="%file_url%" title="Download %file_display_name%"><img align="middle" src="%file_icon_url%" alt="%file_display_name%" height="80"/></a></div>
<div class="wpfilebase-rightcol">
<div class="wpfilebase-filetitle">
<a href="%file_url%" title="Download %file_display_name%">%file_info/tags/id3v2/title%</a><br />
%file_info/tags/id3v2/artist%<br />
%file_info/tags/id3v2/album%<br />
<!-- IF %file_post_id% AND %post_id% != %file_post_id% --><a href="%file_post_url%" class="wpfilebase-postlink">%\'View post\'%</a><!-- ENDIF -->
</div>
</div>
<div class="wpfilebase-fileinfo">
%file_info/playtime_string%<br />
%file_info/bitrate%<br />
%file_size%<br />
%file_hits% %\'Downloads\'%<br />
</div>
<div style="clear: both;"></div>
</div>', 'html5_video' => "<video width='%file_info/video/resolution_x%' height='%file_info/video/resolution_y%' controls>\n <source src='%file_url%' type='%file_type%'>\nYour browser does not support the video tag. <a href='%file_url%'>Open Video directly</a>.\n</video>", 'data-table' => '<tr><td><a href="%file_url%">%file_display_name%</a></td><td>%file_size%</td><td>%file_hits%</td></tr>');
$def_tpls_cat = array('filebrowser' => '%cat_small_icon% <a href="%cat_url%" onclick="return false;">%cat_name%</a>', '3-col-row' => '<tr><td colspan="3" style="text-align:center;font-size:120%;">%cat_name%</td></tr>', 'data-table' => '<!-- EMPTY: categories should not be listed in DataTables -->');
add_option(WPFB_OPT_NAME . '_tpls_file', $def_tpls_file, null, 'no');
add_option(WPFB_OPT_NAME . '_tpls_cat', $def_tpls_cat, null, 'no');
add_option(WPFB_OPT_NAME . '_ptpls_file', array(), null, 'no');
add_option(WPFB_OPT_NAME . '_ptpls_cat', array(), null, 'no');
$def_tpls_list = array('default' => array('header' => '', 'footer' => '', 'file_tpl_tag' => 'default', 'cat_tpl_tag' => 'default'), 'table' => array('header' => '%search_form%
<table>
<thead>
<tr><th scope="col"><a href="%sortlink:file_name%">Name</a></th><th scope="col"><a href="%sortlink:file_size%">Size</a></th><th scope="col"><a href="%sortlink:file_hits%">Hits</a></th></tr>
</thead>
<tfoot>
<tr><th scope="col"><a href="%sortlink:file_name%">Name</a></th><th scope="col"><a href="%sortlink:file_size%">Size</a></th><th scope="col"><a href="%sortlink:file_hits%">Hits</a></th></tr>
</tfoot>
<tbody>', 'footer' => '</tbody>
</table>
<div class="tablenav-pages">%page_nav%</div>', 'file_tpl_tag' => '3-col-row', 'cat_tpl_tag' => '3-col-row'), 'mp3-list' => array('header' => '', 'footer' => '', 'file_tpl_tag' => 'mp3', 'cat_tpl_tag' => 'default'), 'data-table' => array('header' => '%print_script:jquery-dataTables%
%print_style:jquery-dataTables%
<table id="wpfb-data-table-%uid%">
<thead>
<tr><th scope="col">Name</th><th scope="col">Size</th><th scope="col">Hits</th></tr>
</thead>
<tbody>', 'footer' => '</tbody>
</table>
<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function() {
jQuery(\'#wpfb-data-table-%uid%\').DataTable();
} );
</script>', 'file_tpl_tag' => 'data-table', 'cat_tpl_tag' => 'data-table'));
add_option(WPFB_OPT_NAME . '_list_tpls', $def_tpls_list, null, 'no');
// delete old (<0.2.0) tpl options and copy to new
$old_tpls = get_option(WPFB_OPT_NAME . '_tpls');
delete_option(WPFB_OPT_NAME . '_tpls');
delete_option(WPFB_OPT_NAME . '_tpls_parsed');
if (!empty($old_tpls)) {
$file_tpls = array_merge(WPFB_Core::GetFileTpls(), $old_tpls);
WPFB_Core::SetFileTpls($file_tpls);
}
// add protected tpls
$tpls_file = get_option(WPFB_OPT_NAME . '_tpls_file');
$tpls_cat = get_option(WPFB_OPT_NAME . '_tpls_cat');
$tpls_list = get_option(WPFB_OPT_NAME . '_list_tpls');
wpfb_loadclass('AdminGuiTpls');
$default_templates = WPFB_AdminGuiTpls::$protected_tags;
// add new data table template
if (!empty($old_ver)) {
if (version_compare($old_ver, '0.2.9.22') < 0) {
$default_templates[] = 'data-table';
$default_templates[] = 'download-button';
}
}
foreach ($default_templates as $pt) {
if (empty($tpls_file[$pt]) && !empty($def_tpls_file[$pt])) {
$tpls_file[$pt] = $def_tpls_file[$pt];
}
if (empty($tpls_cat[$pt]) && !empty($def_tpls_cat[$pt])) {
$tpls_cat[$pt] = $def_tpls_cat[$pt];
}
if (empty($tpls_list[$pt]) && !empty($def_tpls_list[$pt])) {
$tpls_list[$pt] = $def_tpls_list[$pt];
}
}
update_option(WPFB_OPT_NAME . '_tpls_file', $tpls_file);
update_option(WPFB_OPT_NAME . '_tpls_cat', $tpls_cat);
update_option(WPFB_OPT_NAME . '_list_tpls', $tpls_list);
WPFB_Admin::ParseTpls();
}
示例4: Display
static function Display()
{
global $wpdb, $user_ID, $user_identity;
wpfb_loadclass('Admin', 'Output', 'TplLib', 'ListTpl');
WPFB_Core::PrintJS();
$_POST = stripslashes_deep($_POST);
$_GET = stripslashes_deep($_GET);
$action = !empty($_POST['action']) ? $_POST['action'] : (!empty($_GET['action']) ? $_GET['action'] : '');
$clean_uri = remove_query_arg(array('message', 'action', 'file_id', 'cat_id', 'deltpl', 'hash_sync'));
// keep search keyword
// security nonce
if (!empty($action) && $action != 'edit' && !check_admin_referer($action . '-' . $_REQUEST['type'], 'wpfb-tpl-nonce')) {
wp_die(__('Cheatin’ uh?'));
}
if ($action == 'add' || $action == 'update') {
if (empty($_POST['type'])) {
wp_die(__('Type missing!', 'wp-filebase'));
}
if (empty($_POST['tpltag'])) {
wp_die(__('Please enter a template tag.', 'wp-filebase'));
}
$type = $_POST['type'];
$for_cat = $type == 'cat';
$tpl_tag = preg_replace('/[^a-z0-9_-]/', '', str_replace(' ', '_', strtolower($_POST['tpltag'])));
if (empty($tpl_tag)) {
wp_die('Tag is invalid!');
}
if ($type == 'list') {
$data = array('header' => $_POST['tpl-list-header'], 'footer' => $_POST['tpl-list-footer'], 'cat_tpl_tag' => $_POST['tpl-list-cat-tpl'], 'file_tpl_tag' => $_POST['tpl-list-file-tpl']);
$tpl = new WPFB_ListTpl($tpl_tag, $data);
$tpl->Save();
} else {
if (empty($_POST['tplcode'])) {
wp_die('Please enter some template code.');
}
if ($tpl_tag == 'default') {
// hanle default tpls a bit different
WPFB_Core::UpdateOption("template_{$type}", $_POST['tplcode']);
} else {
$tpls = WPFB_Core::GetTpls($type);
$tpls[$tpl_tag] = $_POST['tplcode'];
if ($for_cat) {
WPFB_Core::SetCatTpls($tpls);
} else {
WPFB_Core::SetFileTpls($tpls);
}
}
}
WPFB_Admin::ParseTpls();
unset($_POST['type'], $_POST['tpltag'], $_POST['tplcode']);
} elseif ($action == 'del') {
if (!empty($_GET['type']) && !empty($_GET['tpl']) && !in_array($_GET['tpl'], self::$protected_tags)) {
$type = $_GET['type'];
if ($type == 'list') {
$tpl = WPFB_ListTpl::Get($_GET['tpl']);
if ($tpl) {
$tpl->Delete();
}
}
$for_cat = $type == 'cat';
$tpls = WPFB_Core::GetTpls($type);
unset($tpls['default']);
if (!empty($tpls)) {
unset($tpls[$_GET['tpl']]);
if ($for_cat) {
WPFB_Core::SetCatTpls($tpls);
} else {
WPFB_Core::SetFileTpls($tpls);
}
}
unset($_POST['type'], $_POST['tpl']);
}
WPFB_Admin::ParseTpls();
}
if (!empty($_POST['reset-tpls'])) {
wpfb_call('Setup', 'ResetTpls');
// also reset default templates stored in settings
wpfb_loadclass('Admin');
$settings_schema = WPFB_Admin::SettingsSchema();
WPFB_Core::UpdateOption('template_file', $settings_schema['template_file']['default']);
WPFB_Core::UpdateOption('template_cat', $settings_schema['template_cat']['default']);
WPFB_Admin::ParseTpls();
}
?>
<script type="text/javascript">
function WPFB_GenSuccess(data, textStatus, request)
{
this.html(data);
}
function WPFB_PreviewTpl(ta, ty)
{
var tplc = (ty != 'list') ? jQuery(ta).val() : {
header: jQuery('#tpl-list-header').val(),
footer: jQuery('#tpl-list-footer').val(),
file_tpl_tag: jQuery('#tpl-list-file-tpl').val(),
cat_tpl_tag: jQuery('#tpl-list-cat-tpl').val()
};
//.........这里部分代码省略.........
示例5: AddTpls
static function AddTpls($old_ver = null)
{
$def_tpls_file = array('filebrowser' => '%file_small_icon% <a href="%file_url%" title="Download %file_display_name%">%file_display_name%</a> (%file_size%)', 'download-button' => '<div style="text-align:center; width:250px; margin: auto; font-size:smaller;"><a href="%file_url%" class="wpfb-dlbtn"><div></div></a>
%file_display_name% (%file_size%, %file_hits% downloads)
</div>', 'image_320' => '[caption id="file_%file_id%" align="alignnone" width="320" caption="<!-- IF %file_description% -->%file_description%<!-- ELSE -->%file_display_name%<!-- ENDIF -->"]<img class="size-full" title="%file_display_name%" src="%file_url%" alt="%file_display_name%" width="320" />[/caption]' . "\n\n", 'thumbnail' => '<div class="wpfilebase-fileicon"><a href="%file_url%" title="Download %file_display_name%"><img align="middle" src="%file_icon_url%" /></a></div>' . "\n", 'simple' => '<p><img src="%file_icon_url%" style="height:20px;vertical-align:middle;" /> <a href="%file_url%" title="Download %file_display_name%">%file_display_name%</a> (%file_size%)</p>', '3-col-row' => '<tr><td><a href="%file_url%">%file_display_name%</a></td><td>%file_size%</td><td>%file_hits%</td></tr>', 'mp3' => '<div class="wpfilebase-attachment">
<div class="wpfilebase-fileicon"><a href="%file_url%" title="Download %file_display_name%"><img align="middle" src="%file_icon_url%" alt="%file_display_name%" height="80"/></a></div>
<div class="wpfilebase-rightcol">
<div class="wpfilebase-filetitle">
<a href="%file_url%" title="Download %file_display_name%">%file_info/tags/id3v2/title%</a><br />
%file_info/tags/id3v2/artist%<br />
%file_info/tags/id3v2/album%<br />
<!-- IF %file_post_id% AND %post_id% != %file_post_id% --><a href="%file_post_url%" class="wpfilebase-postlink">%\'View post\'%</a><!-- ENDIF -->
</div>
</div>
<div class="wpfilebase-fileinfo">
%file_info/playtime_string%<br />
%file_info/bitrate%<br />
%file_size%<br />
%file_hits% %\'Downloads\'%<br />
</div>
<div style="clear: both;"></div>
</div>', 'flv-player' => "<!-- the player only works when permalinks are enabled!!! -->\r\n <object width='%file_info/video/resolution_x%' height='%file_info/video/resolution_y%' id='flvPlayer%uid%'>\r\n <param name='allowFullScreen' value='true'>\r\n <param name='allowScriptAccess' value='always'> \r\n <param name='movie' value='%wpfb_url%extras/flvplayer/OSplayer.swf?movie=%file_url_encoded%&btncolor=0x333333&accentcolor=0x31b8e9&txtcolor=0xdddddd&volume=30&autoload=on&autoplay=off&vTitle=%file_display_name%&showTitle=yes'>\r\n <embed src='%wpfb_url%extras/flvplayer/OSplayer.swf?movie=%file_url_encoded%&btncolor=0x333333&accentcolor=0x31b8e9&txtcolor=0xdddddd&volume=30&autoload=on&autoplay=off&vTitle=%file_display_name%&showTitle=yes' width='%file_info/video/resolution_x%' height='%file_info/video/resolution_y%' allowFullScreen='true' type='application/x-shockwave-flash' allowScriptAccess='always'>\r\n </object>", 'data-table' => '<tr><td><a href="%file_url%">%file_display_name%</a></td><td>%file_size%</td><td>%file_hits%</td></tr>');
$def_tpls_cat = array('filebrowser' => '%cat_small_icon% <a href="%cat_url%" onclick="return false;">%cat_name%</a>', '3-col-row' => '<tr><td colspan="3" style="text-align:center;font-size:120%;">%cat_name%</td></tr>', 'data-table' => '<!-- EMPTY: categories should not be listed in DataTables -->');
add_option(WPFB_OPT_NAME . '_tpls_file', $def_tpls_file, null, 'no');
add_option(WPFB_OPT_NAME . '_tpls_cat', $def_tpls_cat, null, 'no');
add_option(WPFB_OPT_NAME . '_ptpls_file', array(), null, 'no');
add_option(WPFB_OPT_NAME . '_ptpls_cat', array(), null, 'no');
$def_tpls_list = array('default' => array('header' => '', 'footer' => '', 'file_tpl_tag' => 'default', 'cat_tpl_tag' => 'default'), 'table' => array('header' => '%search_form%
<table>
<thead>
<tr><th scope="col"><a href="%sortlink:file_name%">Name</a></th><th scope="col"><a href="%sortlink:file_size%">Size</a></th><th scope="col"><a href="%sortlink:file_hits%">Hits</a></th></tr>
</thead>
<tfoot>
<tr><th scope="col"><a href="%sortlink:file_name%">Name</a></th><th scope="col"><a href="%sortlink:file_size%">Size</a></th><th scope="col"><a href="%sortlink:file_hits%">Hits</a></th></tr>
</tfoot>
<tbody>', 'footer' => '</tbody>
</table>
<div class="tablenav-pages">%page_nav%</div>', 'file_tpl_tag' => '3-col-row', 'cat_tpl_tag' => '3-col-row'), 'mp3-list' => array('header' => '', 'footer' => '', 'file_tpl_tag' => 'mp3', 'cat_tpl_tag' => 'default'), 'data-table' => array('header' => '%print_script:jquery-dataTables%
%print_style:jquery-dataTables%
<table id="wpfb-data-table-%uid%">
<thead>
<tr><th scope="col">Name</th><th scope="col">Size</th><th scope="col">Hits</th></tr>
</thead>
<tbody>', 'footer' => '</tbody>
</table>
<script type="text/javascript" charset="utf-8">
jQuery(document).ready(function() {
jQuery(\'#wpfb-data-table-%uid%\').dataTable();
} );
</script>', 'file_tpl_tag' => 'data-table', 'cat_tpl_tag' => 'data-table'));
add_option(WPFB_OPT_NAME . '_list_tpls', $def_tpls_list, null, 'no');
// delete old (<0.2.0) tpl options and copy to new
$old_tpls = get_option(WPFB_OPT_NAME . '_tpls');
delete_option(WPFB_OPT_NAME . '_tpls');
delete_option(WPFB_OPT_NAME . '_tpls_parsed');
if (!empty($old_tpls)) {
$file_tpls = array_merge(WPFB_Core::GetFileTpls(), $old_tpls);
WPFB_Core::SetFileTpls($file_tpls);
}
// add protected tpls
$tpls_file = get_option(WPFB_OPT_NAME . '_tpls_file');
$tpls_cat = get_option(WPFB_OPT_NAME . '_tpls_cat');
$tpls_list = get_option(WPFB_OPT_NAME . '_list_tpls');
wpfb_loadclass('AdminGuiTpls');
$default_templates = WPFB_AdminGuiTpls::$protected_tags;
// add new data table template
if (!empty($old_ver)) {
if (version_compare($old_ver, '0.2.9.22') < 0) {
$default_templates[] = 'data-table';
$default_templates[] = 'download-button';
}
}
foreach ($default_templates as $pt) {
if (empty($tpls_file[$pt]) && !empty($def_tpls_file[$pt])) {
$tpls_file[$pt] = $def_tpls_file[$pt];
}
if (empty($tpls_cat[$pt]) && !empty($def_tpls_cat[$pt])) {
$tpls_cat[$pt] = $def_tpls_cat[$pt];
}
if (empty($tpls_list[$pt]) && !empty($def_tpls_list[$pt])) {
$tpls_list[$pt] = $def_tpls_list[$pt];
}
}
update_option(WPFB_OPT_NAME . '_tpls_file', $tpls_file);
update_option(WPFB_OPT_NAME . '_tpls_cat', $tpls_cat);
update_option(WPFB_OPT_NAME . '_list_tpls', $tpls_list);
WPFB_Admin::ParseTpls();
}