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 }
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 }
static function ResetOptions() { $traffic = isset(WPFB_Core::$settings->traffic_stats) ? WPFB_Core::$settings->traffic_stats : null; // keep stats self::RemoveOptions(); self::AddOptions(); if (!is_null($traffic)) { WPFB_Core::UpdateOption('traffic_stats', $traffic); } WPFB_Admin::ParseTpls(); }
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() }; var previewId = 'tplinp_'+ty+'_preview'; jQuery.ajax({ type: 'POST', url: '<?php echo WPFB_Core::$ajax_url; ?> ', data: { wpfb_action: "tpl-sample", tpl: tplc, type: ty }, async: true, success: WPFB_GenSuccess, context: jQuery('#'+previewId) }); } jQuery(document).ready( function() { try { jQuery('#wpfb-tabs').tabs(); } catch(ex) {} }); </script> <?php switch ($action) { case 'edit': if (empty($_REQUEST['type']) || empty($_REQUEST['tpl'])) { wp_die('Request error'); } $tpl_tag = $_REQUEST['tpl']; $type = $_REQUEST['type']; if ($type == 'list') { if (WPFB_ListTpl::Get($tpl_tag) == null) { wp_die('No such template!'); } } else { $for_cat = $type == 'cat'; $tpl_src = WPFB_Core::GetTpls($type, $tpl_tag); if (empty($tpl_src)) { wp_die('No such template!'); } } echo '<div class="wrap">'; self::TplForm($type, $tpl_tag); echo '</div>'; break; default: ?> <div class="wrap"> <h2><?php _e('Templates', 'wp-filebase'); if (empty(WPFB_Core::$settings->disable_css) && current_user_can('edit_themes')) { ?> <a href="<?php echo admin_url('admin.php?page=wpfilebase_css'); ?> " class="add-new-h2"><?php _e('Edit Stylesheet', 'wp-filebase'); ?> </a> <?php } ?> <a href="<?php echo add_query_arg('iframe-preview', (int) empty($_GET['iframe-preview'])); ?> " class="add-new-h2">iframe preview</a> </h2> <div id="wpfb-tabs"> <ul class="wpfb-tab-menu"> <li><a href="#file"><?php _e('Files', 'wp-filebase'); ?> </a></li> <li><a href="#cat"><?php _e('Categories'); ?> </a></li> <li><a href="#list"><?php _e('File List', 'wp-filebase'); ?> </a></li> </ul> <div id="file" class="wrap"> <p><?php _e('Templates used for single embedded files or file lists.', 'wp-filebase'); ?> </p> <?php self::TplsTable('file'); ?> </div> <div id="cat" class="wrap"> <p><?php _e('These templates can be used for categories.', 'wp-filebase'); ?> </p> <?php self::TplsTable('cat'); ?> </div> <div id="list" class="wrap"> <p><?php _e('A list-template consists of header, footer and file template. It can optionally have a category template to list sub-categories.', 'wp-filebase'); ?> </p> <?php self::TplsTable('list'); ?> </div> <div id="browser" class="wrap"> </div> </div> <!-- tabs --> <form action="<?php echo remove_query_arg(array('action', 'type', 'tpl')); ?> " method="post" onsubmit="return confirm('<?php _e('This will reset all File, Category and List Templates! Are your sure?', 'wp-filebase'); ?> ');"><p> <input type="submit" name="reset-tpls" value="<?php _e('Reset all Templates to default', 'wp-filebase'); ?> " class="button" /> </p></form> </div> <?php break; } }
static function ResetOptions() { $traffic = WPFB_Core::$settings->traffic_stats; // keep stats self::RemoveOptions(); self::AddOptions(); WPFB_Core::UpdateOption('traffic_stats', $traffic); WPFB_Admin::ParseTpls(); }