本文整理汇总了PHP中wpfb_loadclass函数的典型用法代码示例。如果您正苦于以下问题:PHP wpfb_loadclass函数的具体用法?PHP wpfb_loadclass怎么用?PHP wpfb_loadclass使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpfb_loadclass函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Display
static function Display()
{
global $wpdb, $user_ID;
wpfb_loadclass('Admin', 'Output');
$_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
WPFB_Admin::PrintFlattrHead();
?>
<div class="wrap"><?php
switch ($action) {
default:
?>
<div id="wpfilebase-donate">
<p><?php
_e('If you like WP-Filebase I would appreciate a small donation to support my work. You can additionally add an idea to make WP-Filebase even better. Just click the button below. Thank you!', WPFB);
?>
</p>
<?php
WPFB_Admin::PrintPayPalButton();
WPFB_Admin::PrintFlattrButton();
?>
</div>
<?php
break;
}
?>
</div> <!-- wrap -->
<?php
}
示例2: testCreateTree
function testCreateTree()
{
$this->testSetUser();
wpfb_loadclass('Admin');
/** @var WPFB_Category $parent */
$parent = null;
/** @var WPFB_Category[] $cats */
$cats = array();
for ($d = 0; $d < 4; $d++) {
$res = WPFB_Admin::InsertCategory(array('cat_name' => "layer {$d}", 'cat_parent' => $parent ? $parent->GetId() : 0));
$this->assertEmpty($res['error']);
/** @var WPFB_Category $cat */
$cat = $res['cat'];
$this->assertTrue($parent ? $cat->GetParent()->Equals($parent) : is_null($cat->GetParent()));
$this->assertTrue(is_dir($cat->GetLocalPath()));
$cats[] = $cat;
$parent = $cat;
}
// print_r(array_map( function($c) { return strval($c);}, $cats));
$files = new TestFileSet();
$res = WPFB_Admin::InsertFile(array('file_remote_uri' => 'file://' . $files->getImageBanner(), 'file_category' => $parent));
$this->assertEmpty($res['error'], $res['error']);
/** @var WPFB_File $file01 */
$file01 = $res['file'];
}
示例3: Create
public static function Create($form_url, $is_edit = false)
{
$uploader_class = version_compare(get_bloginfo('version'), '3.2.1') <= 0 ? 'SWFUpload' : 'PLUpload';
wpfb_loadclass($uploader_class);
$uploader_class = "WPFB_" . $uploader_class;
return new $uploader_class($form_url, $is_edit);
}
示例4: 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
}
示例5: _manually_load_plugin
function _manually_load_plugin()
{
require dirname(dirname(__FILE__)) . '/wp-filebase.php';
add_action('init', function () {
require_once dirname(dirname(__FILE__)) . '/classes/Core.php';
wpfb_loadclass('Setup');
WPFB_Setup::OnActivateOrVerChange(null);
WPFB_Core::$settings = (object) get_option(WPFB_OPT_NAME);
WPFB_Core::InitClass();
}, 1);
}
示例6: AnalyzeFile
static function AnalyzeFile($file)
{
@ini_set('max_execution_time', '0');
@set_time_limit(0);
$filename = is_string($file) ? $file : $file->GetLocalPath();
$info = WPFB_Core::$settings->disable_id3 ? array() : self::GetEngine()->analyze($filename);
if (!empty($_GET['debug'])) {
wpfb_loadclass('Sync');
WPFB_Sync::PrintDebugTrace("file_analyzed_" . $file->GetLocalPathRel());
}
return $info;
}
示例7: Check
static function Check($tpl)
{
$result = array('error' => false, 'msg' => '', 'line' => '');
wpfb_loadclass('File');
$f = new WPFB_File();
$tpl = 'return (' . $tpl . ');';
if (!@eval($tpl)) {
$result['error'] = true;
$err = error_get_last();
if (!empty($err)) {
$result['msg'] = $err['message'];
$result['line'] = $err['line'];
}
}
return $result;
}
示例8: test_new_file_remote
function test_new_file_remote()
{
$usr = wp_create_user('test_admin', 'test_admin');
$this->assertNotWPError($usr);
wp_set_current_user($usr);
wpfb_loadclass('Admin');
$res = WPFB_Admin::InsertFile(array('file_remote_uri' => 'https://wpfilebase.com/wp-content/blogs.dir/2/files/2015/03/banner_023.png'));
$this->assertEmpty($res['error'], $res['error']);
/** @var WPFB_File $file */
$file = $res['file'];
$this->assertTrue($file->IsLocal(), 'IsLocal false');
$this->assertFileExists($file->GetLocalPath());
$this->assertNotEmpty($file->file_thumbnail);
$this->assertFileExists($file->GetThumbPath());
$this->assertTrue($file->Remove());
}
示例9: __construct
function __construct()
{
wpfb_loadclass('Download', 'Admin');
$dir = WPFB_Core::UploadDir() . '/.tmp/';
WPFB_Admin::Mkdir($dir);
$test_files = array('banner.png' => 'https://wpfilebase.com/wp-content/blogs.dir/2/files/2015/03/banner_023.png', 'small.txt' => 'https://wpfilebase.com/robots.txt');
$this->local_files = array();
foreach ($test_files as $f => $u) {
$fn = $dir . $f;
$this->local_files[$f] = $fn;
if (file_exists($fn)) {
continue;
}
echo "Downloading test file {$u}\n";
WPFB_Download::SideloadFile($u, $fn);
}
}
示例10: test_cat_tree
/**
* @depends test_new_cat
*/
function test_cat_tree()
{
wpfb_loadclass('Admin');
$depth = 4;
/** @var WPFB_Category $parent */
$parent = null;
$cats = array();
for ($d = 0; $d < $depth; $d++) {
$res = WPFB_Admin::InsertCategory(array('cat_name' => "layer {$d}", 'cat_parent' => $parent ? $parent->GetId() : 0));
$this->assertEmpty($res['error']);
/** @var WPFB_Category $cat */
$cat = $res['cat'];
$this->assertTrue($parent ? $cat->GetParent()->Equals($parent) : is_null($cat->GetParent()));
$cats[] = $cat;
}
foreach (array_reverse($cats) as $cat) {
$res = $cat->Delete();
$this->assertEmpty($res['error'], $res['error']);
}
}
示例11: 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
}
示例12: analyzeFile
/**
* Intesive analysis of file contents. Does _not_ make changes to the file or store anything in the DB!
*
* @param type $file
* @return type
*/
private static function analyzeFile($file)
{
@ini_set('max_execution_time', '0');
@set_time_limit(0);
$filename = is_string($file) ? $file : $file->GetLocalPath();
$times = array();
$times['analyze'] = microtime(true);
$info = WPFB_Core::$settings->disable_id3 ? array() : self::GetEngine()->analyze($filename);
if (!WPFB_Core::$settings->disable_id3 && class_exists('getid3_lib')) {
getid3_lib::CopyTagsToComments($info);
}
if (!empty($_GET['debug'])) {
wpfb_loadclass('Sync');
WPFB_Sync::PrintDebugTrace("file_analyzed_" . $file->GetLocalPathRel());
}
$times['end'] = microtime(true);
$t_keys = array_keys($times);
$into['debug'] = array('timestamp' => $times[$t_keys[0]], 'timings' => array());
for ($i = 1; $i < count($t_keys); $i++) {
$info['debug']['timings'][$t_keys[$i - 1]] = round(($times[$t_keys[$i]] - $times[$t_keys[$i - 1]]) * 1000);
}
return $info;
}
示例13: OnActivateOrVerChange
static function OnActivateOrVerChange($old_ver = null)
{
global $wpdb;
// make sure that either wp-filebase or wp-filebase pro is enabled bot not both!
if (!function_exists('is_plugin_active')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
if (is_plugin_active('wp-filebase-pro/wp-filebase.php')) {
deactivate_plugins('wp-filebase/wp-filebase.php');
}
wpfb_loadclass('Admin', 'File', 'Category');
self::SetupDBTables($old_ver);
$old_options = get_option(WPFB_OPT_NAME);
self::AddOptions();
self::AddTpls($old_ver);
$new_options = get_option(WPFB_OPT_NAME);
WPFB_Admin::SettingsUpdated($old_options, $new_options);
self::ProtectUploadPath();
$sync_data_file = WPFB_Core::UploadDir() . '/._sync.data';
is_file($sync_data_file) && unlink($sync_data_file);
WPFB_Admin::WPCacheRejectUri(WPFB_Core::$settings->download_base . '/', $old_options['download_base'] . '/');
// TODO, do this in background
if (WPFB_Category::GetNumCats() < self::MANY_CATEGORIES && WPFB_File::GetNumFiles() < self::MANY_FILES) {
// avoid long activation time
wpfb_loadclass('Sync');
WPFB_Sync::SyncCats();
WPFB_Sync::UpdateItemsPath();
}
if (!wp_next_scheduled(WPFB . '_cron')) {
wp_schedule_event(time() + 20, 'hourly', WPFB . '_cron');
}
if (!get_option('wpfb_install_time')) {
add_option('wpfb_install_time', ($ft = (int) mysql2date('U', $wpdb->get_var("SELECT file_mtime FROM {$wpdb->wpfilebase_files} ORDER BY file_mtime ASC LIMIT 1"))) > 0 ? $ft : time(), null, 'no');
}
$wp_upload = wp_upload_dir();
// move old css
if (file_exists(WPFB_Core::GetOldCustomCssPath())) {
$wp_upload_ok = empty($wp_upload['error']) && is_writable($wp_upload['basedir']);
if ($wp_upload_ok && @rename(WPFB_Core::GetOldCustomCssPath(), $wp_upload['basedir'] . '/wp-filebase.css')) {
update_option('wpfb_css', $wp_upload['baseurl'] . '/wp-filebase.css?t=' . time());
}
}
// refresh css URL (in case upload_dir changed or upgrade from free to pro)
update_option('wpfb_css', trailingslashit(file_exists($wp_upload['basedir'] . '/wp-filebase.css') ? $wp_upload['baseurl'] : WPFB_PLUGIN_URI) . 'wp-filebase.css?t=' . time());
flush_rewrite_rules();
// change mapping of file browser folder icons (2340897_sdf.svg => svg-.....svg!)
$image_mappings = array('1449888880_folder.svg' => 'svg-folder.svg', '1449888883_folder.svg' => 'svg-folder-blue.svg', '1449888885_folder-blue.svg' => 'svg-folderblue.svg', '1449888886_folder-green.svg' => 'svg-folder-green.svg');
$folder_icons_base = '/plugins/wp-filebase/images/folder-icons/';
$folder_icon = substr(WPFB_Core::$settings->folder_icon, strlen($folder_icons_base));
if (isset($image_mappings[$folder_icon])) {
WPFB_Core::UpdateOption('folder_icon', $folder_icons_base . $image_mappings[$folder_icon]);
}
//delete_option('wpfilebase_dismiss_support_ending');
// fixes files that where offline
if ($old_ver === "3.4.2") {
$wpdb->query("UPDATE `{$wpdb->wpfilebase_files}` SET file_offline = '0' WHERE 1");
wpfb_loadclass('Sync');
WPFB_Sync::list_files(WPFB_Core::UploadDir());
}
}
示例14: GetSortSql
static function GetSortSql($sort = null, $attach_order = false, $for_cat = false)
{
global $wpdb;
wpfb_loadclass('Output');
list($sort, $sortdir) = WPFB_Output::ParseSorting($sort, $for_cat);
$sort = esc_sql($sort);
$of = $for_cat ? 'cat_order' : 'file_attach_order';
return $attach_order ? "`{$of}` ASC, `{$sort}` {$sortdir}" : "`{$sort}` {$sortdir}";
}
示例15: ChangeCategoryOrName
function ChangeCategoryOrName($new_cat_id, $new_name = null, $add_existing = false, $overwrite = false)
{
// 1. apply new values (inherit permissions if nothing (Everyone) set!)
// 2. check for name collision and rename
// 3. move stuff
// 4. notify parents
// 5. update child paths
if (empty($new_name)) {
$new_name = $this->GetName();
}
$this->Lock(true);
$new_cat_id = intval($new_cat_id);
$old_cat_id = $this->GetParentId();
$old_path_rel = $this->GetLocalPathRel(true);
$old_path = $this->GetLocalPath();
$old_name = $this->GetName();
if ($this->is_file) {
$old_thumb_path = $this->GetThumbPath();
}
$old_cat = $this->GetParent();
$new_cat = WPFB_Category::GetCat($new_cat_id);
if (!$new_cat) {
$new_cat_id = 0;
}
$cat_changed = $new_cat_id != $old_cat_id;
if ($cat_changed && $new_cat_id > 0 && $this->IsAncestorOf($new_cat)) {
return array('error' => __('Cannot move category into a sub-category of itself.', WPFB));
}
if ($this->is_file) {
$this->file_category = $new_cat_id;
$this->file_name = $new_name;
$this->file_category_name = $new_cat_id == 0 ? '' : $new_cat->GetTitle();
} else {
$this->cat_parent = $new_cat_id;
$this->cat_folder = $new_name;
}
// inherit user roles
if (count($this->GetReadPermissions()) == 0) {
$this->SetReadPermissions($new_cat_id != 0 ? $new_cat->GetReadPermissions() : WPFB_Core::$settings->default_roles);
}
// flush cache
$this->last_parent_id = -1;
$new_path_rel = $this->GetLocalPathRel(true);
$new_path = $this->GetLocalPath();
if ($new_path_rel != $old_path_rel) {
$i = 1;
if (!$add_existing) {
$name = $this->GetName();
if ($overwrite) {
if (@file_exists($new_path)) {
$ex_file = WPFB_File::GetByPath($new_path_rel);
if (!is_null($ex_file)) {
$ex_file->Remove();
} else {
@unlink($new_path);
}
}
} else {
// rename item if filename collision (ignore if coliding with $this)
while (@file_exists($new_path) || !is_null($ex_file = WPFB_File::GetByPath($new_path_rel)) && !$this->Equals($ex_file)) {
$i++;
if ($this->is_file) {
$p = strrpos($name, '.');
$this->file_name = $p <= 0 ? "{$name}({$i})" : substr($name, 0, $p) . "({$i})" . substr($name, $p);
} else {
$this->cat_folder = "{$name}({$i})";
}
$new_path_rel = $this->GetLocalPathRel(true);
$new_path = $this->GetLocalPath();
}
}
}
// finally move it!
if (!empty($old_name) && @file_exists($old_path)) {
if ($this->is_file && $this->IsLocal()) {
if (!@rename($old_path, $new_path)) {
return array('error' => sprintf('Unable to move file %s!', $old_path));
}
@chmod($new_path, octdec(WPFB_PERM_FILE));
} else {
if (!@is_dir($new_path)) {
wp_mkdir_p($new_path);
}
wpfb_loadclass('FileUtils');
if (!@WPFB_FileUtils::MoveDir($old_path, $new_path)) {
return array('error' => sprintf('Could not move folder %s to %s', $old_path, $new_path));
}
}
} else {
if ($this->is_category) {
if (!@is_dir($new_path) && !wp_mkdir_p($new_path)) {
return array('error' => sprintf(__('Unable to create directory %s. Is it\'s parent directory writable?'), $new_path));
}
}
}
// move thumb
if ($this->is_file && !empty($old_thumb_path) && @is_file($old_thumb_path)) {
$thumb_path = $this->GetThumbPath();
if ($i > 1) {
$p = strrpos($thumb_path, '-');
//.........这里部分代码省略.........